aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMark Whitley <markw@lineo.com>2001-03-12 20:00:00 +0000
committerMark Whitley <markw@lineo.com>2001-03-12 20:00:00 +0000
commit5ec5415402ee6e4ae21e4a50c04360908325ba81 (patch)
tree74f76156ac9f664a2416ec425f2b4252a6881afe /tests
parent1a49fc5e92e2b6478f46b0e22edd6079b75dc30e (diff)
downloadbusybox-w32-5ec5415402ee6e4ae21e4a50c04360908325ba81.tar.gz
busybox-w32-5ec5415402ee6e4ae21e4a50c04360908325ba81.tar.bz2
busybox-w32-5ec5415402ee6e4ae21e4a50c04360908325ba81.zip
Program for testing concurrent access to syslogd.
Diffstat (limited to 'tests')
-rw-r--r--tests/tst-syslogd.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/tst-syslogd.c b/tests/tst-syslogd.c
new file mode 100644
index 000000000..bae10afdf
--- /dev/null
+++ b/tests/tst-syslogd.c
@@ -0,0 +1,44 @@
1/*
2 * tst-syslogd.c - tests concurrent threads calling syslog
3 *
4 * build with: gcc -Wall tst-syslogd.c -lpthread
5 */
6
7#include <stdio.h>
8#include <pthread.h>
9#include <syslog.h>
10#include <unistd.h>
11
12void *log_func(void *arg)
13{
14 int i;
15 int thrid = (int)arg;
16
17 openlog(NULL, LOG_PERROR | LOG_PID, LOG_USER);
18 for (i = 0; i < 10; i++) {
19 syslog(LOG_DEBUG, "thread %i iter %i\n", thrid, i);
20 sleep(thrid); /* this mixes things up a bit */
21 }
22 closelog();
23
24 return NULL;
25}
26
27int main(int argc, char **argv)
28{
29 pthread_t thr1, thr2, thr3;
30 int id1 = 1;
31 int id2 = 2;
32 int id3 = 3;
33
34 pthread_create(&thr1, NULL, log_func, (void *)id1);
35 pthread_create(&thr2, NULL, log_func, (void *)id2);
36 pthread_create(&thr3, NULL, log_func, (void *)id3);
37
38 pthread_join(thr1, NULL);
39 pthread_join(thr2, NULL);
40 pthread_join(thr3, NULL);
41
42 return 0;
43}
44