From f16ce13525c4b4e00ef8e1f578dc92794fa10506 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Sun, 12 Nov 2023 21:38:09 +0100 Subject: [PATCH] Another easy test from McMini --- MANIFEST.in | 2 ++ teshsuite/mc/CMakeLists.txt | 7 ++--- teshsuite/mc/mcmini/simple_threads_ok.c | 33 ++++++++++++++++++++++ teshsuite/mc/mcmini/simple_threads_ok.tesh | 7 +++++ 4 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 teshsuite/mc/mcmini/simple_threads_ok.c create mode 100644 teshsuite/mc/mcmini/simple_threads_ok.tesh diff --git a/MANIFEST.in b/MANIFEST.in index 3a533855d2..718a59eced 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -696,6 +696,8 @@ include teshsuite/mc/mcmini/simple_semaphores_with_threads_deadlock.c include teshsuite/mc/mcmini/simple_semaphores_with_threads_deadlock.tesh include teshsuite/mc/mcmini/simple_semaphores_with_threads_ok.c include teshsuite/mc/mcmini/simple_semaphores_with_threads_ok.tesh +include teshsuite/mc/mcmini/simple_threads_ok.c +include teshsuite/mc/mcmini/simple_threads_ok.tesh include teshsuite/mc/mutex-handling/mutex-handling.cpp include teshsuite/mc/mutex-handling/mutex-handling.tesh include teshsuite/mc/mutex-handling/without-mutex-handling.tesh diff --git a/teshsuite/mc/CMakeLists.txt b/teshsuite/mc/CMakeLists.txt index 1209bc0aa4..5ec629a0f6 100644 --- a/teshsuite/mc/CMakeLists.txt +++ b/teshsuite/mc/CMakeLists.txt @@ -54,7 +54,6 @@ foreach(x # simple_cond_broadcast_ok simple_cond_broadcast_deadlock # simple_cond_broadcast_with_semaphore_ok # simple_cond_broadcast_with_semaphore_deadlock1 simple_cond_broadcast_with_semaphore_deadlock2 -# simple_threads_ok # simple_cond_deadlock simple_mutex_ok simple_mutex_deadlock @@ -63,15 +62,15 @@ foreach(x simple_semaphore_deadlock simple_semaphores_deadlock simple_semaphores_ok simple_semaphores_with_threads_ok simple_semaphores_with_threads_deadlock -# -# philosophers_spurious_deadlock + simple_threads_ok + barber_shop_ok barber_shop_deadlock philosophers_semaphores_ok philosophers_semaphores_deadlock philosophers_mutex_ok philosophers_mutex_deadlock producer_consumer_ok producer_consumer_deadlock - + # philosophers_spurious_deadlock # infinite no-op loop # producer_consumer_spurious_nok # infinite no-op loop ) diff --git a/teshsuite/mc/mcmini/simple_threads_ok.c b/teshsuite/mc/mcmini/simple_threads_ok.c new file mode 100644 index 0000000000..44c716cf38 --- /dev/null +++ b/teshsuite/mc/mcmini/simple_threads_ok.c @@ -0,0 +1,33 @@ +#include +#include +#include +#include + +static void * thread_doit(void *unused) { + int len = (int) ((drand48() * 5) + 1); + sleep(len); + return NULL; +} + +int main(int argc, char* argv[]) { + if(argc < 2) { + printf("Expected usage: %s THREAD_NUM\n", argv[0]); + return -1; + } + + int thread_num = atoi(argv[1]); + + pthread_t *threads = malloc(sizeof(pthread_t) * thread_num); + + for(int i = 0; i < thread_num; i++) { + pthread_create(&threads[i], NULL, &thread_doit, NULL); + } + + for(int i = 0; i < thread_num; i++) { + pthread_join(threads[i], NULL); + } + + free(threads); + + return 0; +} diff --git a/teshsuite/mc/mcmini/simple_threads_ok.tesh b/teshsuite/mc/mcmini/simple_threads_ok.tesh new file mode 100644 index 0000000000..b8a82c5968 --- /dev/null +++ b/teshsuite/mc/mcmini/simple_threads_ok.tesh @@ -0,0 +1,7 @@ +# We ignore the LD_PRELOAD lines from the expected output because they contain the build path +! ignore .*LD_PRELOAD.* + +$ $VALGRIND_NO_TRACE_CHILDREN ${bindir:=.}/../../bin/simgrid-mc --cfg=model-check/reduction:odpor --cfg=model-check/setenv:LD_PRELOAD=${libdir:=.}/libsgmalloc.so:${libdir:=.}/libsthread.so ${bindir:=.}/mcmini/mcmini-simple_threads_ok 3 +> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'model-check/reduction' to 'odpor' +> [0.000000] [mc_dfs/INFO] Start a DFS exploration. Reduction is: odpor. +> [0.000000] [mc_dfs/INFO] DFS exploration ended. 7 unique states visited; 0 backtracks (0 transition replays, 7 states visited overall) \ No newline at end of file -- 2.20.1