feat: add new test
This commit is contained in:
parent
1505a4d8ef
commit
6d97e0ee60
2
Makefile
2
Makefile
@ -6,7 +6,7 @@ install_dir?=install
|
|||||||
# Comment out the bins that doesn't need to be compiled
|
# Comment out the bins that doesn't need to be compiled
|
||||||
bbins+=$(wildcard ${tst_dir}/*.c)
|
bbins+=$(wildcard ${tst_dir}/*.c)
|
||||||
bins=$(filter-out ${tst_dir}/51-fibonacci.c ${tst_dir}/71-preemption.c, ${bbins})
|
bins=$(filter-out ${tst_dir}/51-fibonacci.c ${tst_dir}/71-preemption.c, ${bbins})
|
||||||
all_bins=01-main 02-switch 03-equity 11-join 12-join-main 21-create-many 22-create-many-recursive 23-create-many-once 31-switch-many 32-switch-many-join 33-switch-many-cascade 51-fibonacci 52-dac-sum 61-mutex 62-mutex 63-mutex-equity 64-mutex-join 71-preemption 81-deadlock
|
all_bins=01-main 02-switch 03-equity 11-join 12-join-main 13-join-switch 21-create-many 22-create-many-recursive 23-create-many-once 31-switch-many 32-switch-many-join 33-switch-many-cascade 51-fibonacci 52-dac-sum 61-mutex 62-mutex 63-mutex-equity 64-mutex-join 71-preemption 81-deadlock
|
||||||
|
|
||||||
bins_target=$(patsubst %.c,${build_dir}/%,${bins})
|
bins_target=$(patsubst %.c,${build_dir}/%,${bins})
|
||||||
install_bins_targets=$(patsubst ${tst_dir}/%.c,${install_dir}/bin/%,${bins})
|
install_bins_targets=$(patsubst ${tst_dir}/%.c,${install_dir}/bin/%,${bins})
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
tst_dir=tst
|
tst_dir=tst
|
||||||
filenames="01-main 02-switch 03-equity 11-join 12-join-main 21-create-many 22-create-many-recursive 23-create-many-once 31-switch-many 32-switch-many-join 33-switch-many-cascade 51-fibonacci 61-mutex 62-mutex 63-mutex-equity 64-mutex-join 71-preemption 81-deadlock"
|
filenames="01-main 02-switch 03-equity 11-join 12-join-main 13-join-switch 21-create-many 22-create-many-recursive 23-create-many-once 31-switch-many 32-switch-many-join 33-switch-many-cascade 51-fibonacci 61-mutex 62-mutex 63-mutex-equity 64-mutex-join 71-preemption 81-deadlock"
|
||||||
mkdir -p "${tst_dir}"
|
mkdir -p "${tst_dir}"
|
||||||
|
|
||||||
for filename in ${filenames}
|
for filename in ${filenames}
|
||||||
|
44
tst/13-join-switch.c
Normal file
44
tst/13-join-switch.c
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include "thread.h"
|
||||||
|
|
||||||
|
/* test du join d'un thread qui fait plein de yield().
|
||||||
|
*
|
||||||
|
* le programme doit retourner correctement.
|
||||||
|
* valgrind doit être content.
|
||||||
|
*
|
||||||
|
* support nécessaire:
|
||||||
|
* - thread_create()
|
||||||
|
* - thread_exit()
|
||||||
|
* - thread_join() avec récupération valeur de retour, avec thread_exit()
|
||||||
|
* sur un thread qui yield() plusieurs fois vers celui qui joine.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static void * thfunc(void *dummy __attribute__((unused)))
|
||||||
|
{
|
||||||
|
unsigned i;
|
||||||
|
for(i=0; i<10; i++) {
|
||||||
|
printf(" le fils yield\n");
|
||||||
|
thread_yield();
|
||||||
|
}
|
||||||
|
thread_exit((void*)0xdeadbeef);
|
||||||
|
return NULL; /* unreachable, shut up the compiler */
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
thread_t th;
|
||||||
|
int err;
|
||||||
|
void *res = NULL;
|
||||||
|
|
||||||
|
err = thread_create(&th, thfunc, NULL);
|
||||||
|
assert(!err);
|
||||||
|
|
||||||
|
printf("le main joine...\n");
|
||||||
|
err = thread_join(th, &res);
|
||||||
|
assert(!err);
|
||||||
|
assert(res == (void*) 0xdeadbeef);
|
||||||
|
|
||||||
|
printf("join OK\n");
|
||||||
|
return 0;
|
||||||
|
}
|
@ -7,7 +7,8 @@
|
|||||||
|
|
||||||
/* test de plein de switch pendant que N-1 threads sont bloqués dans join
|
/* test de plein de switch pendant que N-1 threads sont bloqués dans join
|
||||||
*
|
*
|
||||||
* La durée du programme doit etre proportionnelle au nombre de threads et de yields donnés en argument
|
* La durée du programme doit etre proportionnelle au nombre de yields
|
||||||
|
* mais ne pas varier avec le nombre de threads donné en argument.
|
||||||
*
|
*
|
||||||
* support nécessaire:
|
* support nécessaire:
|
||||||
* - thread_create()
|
* - thread_create()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user