tests: add a glib based crash test 40/103540/4
authorŁukasz Stelmach <l.stelmach@samsung.com>
Fri, 2 Dec 2016 12:20:39 +0000 (13:20 +0100)
committerŁukasz Stelmach <l.stelmach@samsung.com>
Thu, 8 Dec 2016 16:24:24 +0000 (17:24 +0100)
Change-Id: Ib5c2a176e0108b1fa20cbd0d156fb1f29139b8fa

tests/CMakeLists.txt
tests/test2.c [new file with mode: 0644]

index 043bdcc..5057355 100644 (file)
@@ -1,4 +1,6 @@
 # tests
+INCLUDE(FindPkgConfig)
+
 set(CMAKE_C_FLAGS "-g -O0 -fno-omit-frame-pointer")
 
 if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armv7l")
@@ -9,3 +11,8 @@ add_executable(test1-crash test1.c)
 add_executable(test1-sleep test1.c)
 add_executable(test1-ill test1.c)
 
+pkg_check_modules (GLIB2 glib-2.0)
+
+add_executable(test2 test2.c)
+target_include_directories(test2 SYSTEM PUBLIC ${GLIB2_INCLUDE_DIRS})
+target_link_libraries(test2 ${GLIB2_LDFLAGS})
diff --git a/tests/test2.c b/tests/test2.c
new file mode 100644 (file)
index 0000000..8d6e516
--- /dev/null
@@ -0,0 +1,20 @@
+#include <glib.h>
+
+gboolean crasher(gpointer data)
+{
+       *(int*)data = 1;
+       return TRUE;
+}
+
+int main()
+{
+       GMainLoop *loop = g_main_loop_new(NULL, FALSE);
+
+       GSource *idle_source = g_idle_source_new();
+       g_source_set_callback(idle_source, crasher, NULL, NULL);
+       g_source_attach(idle_source, g_main_context_ref_thread_default());
+
+       g_main_loop_run(loop);
+
+       return 0;
+}