diff options
author | Angelo Marletta <angelo.marletta@gmail.com> | 2012-06-01 02:00:57 +0100 |
---|---|---|
committer | Angelo Marletta <angelo.marletta@gmail.com> | 2012-06-01 02:00:57 +0100 |
commit | fa8c64b0e28125362c2db8897d92073409c0277a (patch) | |
tree | 4188eafd3cdd8b449e2ea4a098f1f17cf06e7662 /tests | |
parent | b81215b9fbcb0e27d7bb9b4abaa8179ff11b5bfb (diff) | |
download | cpulimit-fa8c64b0e28125362c2db8897d92073409c0277a.tar.gz |
added directory for tests
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile | 13 | ||||
-rwxr-xr-x | tests/busy | bin | 0 -> 8672 bytes | |||
-rw-r--r-- | tests/busy.c | 29 |
3 files changed, 42 insertions, 0 deletions
diff --git a/tests/Makefile b/tests/Makefile new file mode 100644 index 0000000..11f7e2a --- /dev/null +++ b/tests/Makefile @@ -0,0 +1,13 @@ +CC?=gcc +CFLAGS?=-Wall -O2 +TARGETS=busy +LIBS?=-lpthread + +all:: $(TARGETS) + +busy: busy.c $(LIBS) + $(CC) -o busy busy.c $(LIBS) $(CFLAGS) + +clean: + rm -f *~ *.o $(TARGETS) + diff --git a/tests/busy b/tests/busy Binary files differnew file mode 100755 index 0000000..1a8a589 --- /dev/null +++ b/tests/busy diff --git a/tests/busy.c b/tests/busy.c new file mode 100644 index 0000000..bb2e2ed --- /dev/null +++ b/tests/busy.c @@ -0,0 +1,29 @@ +#include <stdio.h> +#include <stdlib.h> +#include <pthread.h> +#include <unistd.h> + +void *loop() +{ + while(1); +} + +int main(int argc, char **argv) { + + int i = 0; + int num_threads = 1; + if (argc == 2) num_threads = atoi(argv[1]); + for (i=0; i<num_threads; i++) + { + pthread_t thread; + int ret; + if ((ret = pthread_create(&thread, NULL, loop, NULL)) != 0) + { + printf("pthread_create() failed. Error code %d\n", ret); + exit(1); + } + } + printf("Press ENTER to exit..."); + getchar(); + return 0; +}
\ No newline at end of file |