aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAngelo Marletta <angelo.marletta@gmail.com>2012-06-01 02:00:57 +0100
committerAngelo Marletta <angelo.marletta@gmail.com>2012-06-01 02:00:57 +0100
commitfa8c64b0e28125362c2db8897d92073409c0277a (patch)
tree4188eafd3cdd8b449e2ea4a098f1f17cf06e7662 /tests
parentb81215b9fbcb0e27d7bb9b4abaa8179ff11b5bfb (diff)
downloadcpulimit-fa8c64b0e28125362c2db8897d92073409c0277a.tar.gz
added directory for tests
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile13
-rwxr-xr-xtests/busybin0 -> 8672 bytes
-rw-r--r--tests/busy.c29
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
new file mode 100755
index 0000000..1a8a589
--- /dev/null
+++ b/tests/busy
Binary files differ
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
Un proyecto texto-plano.xyz