]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - processor-sdk/libmetal.git/commitdiff
generic: mutex ut
authorSam Sortais <sam.sortais@xilinx.com>
Fri, 5 Aug 2016 23:34:48 +0000 (16:34 -0700)
committerWendy Liang <jliang@xilinx.com>
Sat, 13 Aug 2016 06:36:45 +0000 (23:36 -0700)
Signed-off-by: Sam Sortais <sam.sortais@xilinx.com>
test/system/generic/CMakeLists.txt
test/system/generic/mutex.c [new file with mode: 0644]

index a9d6f15074568d98d08d9a505f73775c4a6c8493..b723e98537d31660e762c51804d4c2eda9373401 100644 (file)
@@ -1,6 +1,7 @@
 collect (PROJECT_LIB_TESTS main.c)
 collect (PROJECT_LIB_TESTS alloc.c)
 collect (PROJECT_LIB_TESTS irq.c)
+collect (PROJECT_LIB_TESTS mutex.c)
 
 if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_MACHINE})
   add_subdirectory(${PROJECT_MACHINE})
diff --git a/test/system/generic/mutex.c b/test/system/generic/mutex.c
new file mode 100644 (file)
index 0000000..a0f64fa
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2015, Xilinx Inc. and Contributors. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of Xilinx nor the names of its contributors may be used
+ *    to endorse or promote products derived from this software without
+ *    specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <metal-test.h>
+#include <metal/mutex.h>
+
+static const int mutex_test_count = 1000;
+
+static int mutex(void)
+{
+       metal_mutex_t lock = METAL_MUTEX_INIT;
+       int i;
+
+       for (i = 0; i < mutex_test_count; i++) {
+               metal_mutex_acquire(&lock);
+               metal_mutex_release(&lock);
+       }
+
+       return 0;
+}
+METAL_ADD_TEST(mutex);