revalidator: Fix ukey stats cache updating.
[sliver-openvswitch.git] / tests / test-atomic.c
index 27bf552..b1a5d9d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013 Nicira, Inc.
+ * Copyright (c) 2013, 2014 Nicira, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@
 
 #include "ovs-atomic.h"
 #include "util.h"
+#include "ovstest.h"
 
 #define TEST_ATOMIC_TYPE(ATOMIC_TYPE, BASE_TYPE)        \
     {                                                   \
         ovs_assert(value == 8);                         \
     }
 
-int
-main(void)
+static void
+test_atomic_flag(void)
+{
+    atomic_flag flag = ATOMIC_FLAG_INIT;
+    ovs_assert(atomic_flag_test_and_set(&flag) == false);
+    ovs_assert(atomic_flag_test_and_set(&flag) == true);
+    atomic_flag_clear(&flag);
+    ovs_assert(atomic_flag_test_and_set(&flag) == false);
+}
+
+
+static void
+test_atomic_main(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
 {
     TEST_ATOMIC_TYPE(atomic_char, char);
     TEST_ATOMIC_TYPE(atomic_uchar, unsigned char);
@@ -90,5 +102,7 @@ main(void)
     TEST_ATOMIC_TYPE(atomic_uint64_t, uint64_t);
     TEST_ATOMIC_TYPE(atomic_int64_t, int64_t);
 
-    return 0;
+    test_atomic_flag();
 }
+
+OVSTEST_REGISTER("test-atomic", test_atomic_main);