aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAngelo Marletta <angelo.marletta@gmail.com>2012-06-07 16:42:46 +0100
committerAngelo Marletta <angelo.marletta@gmail.com>2012-06-07 16:42:46 +0100
commit10c2915dd464de44047f182ecae9c8b34e24e772 (patch)
tree63938b5a5ed16bfc9ad865fb1a809ac4f1ec738c /tests
parentcedb83232379d80a9abd2ca72e60d64e5b50d92b (diff)
downloadcpulimit-10c2915dd464de44047f182ecae9c8b34e24e772.tar.gz
new cross-platform code to list processes. works on linux and freebsd
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile11
-rwxr-xr-xtests/busybin5220 -> 5484 bytes
-rwxr-xr-xtests/process_iterator_testbin0 -> 6895 bytes
-rw-r--r--tests/process_iterator_test.c18
4 files changed, 28 insertions, 1 deletions
diff --git a/tests/Makefile b/tests/Makefile
index 11f7e2a..7f1c8b4 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -1,13 +1,22 @@
CC?=gcc
CFLAGS?=-Wall -O2
-TARGETS=busy
+TARGETS=busy process_iterator_test
LIBS?=-lpthread
+UNAME := $(shell uname)
+
+ifeq ($(UNAME), FreeBSD)
+LIBS+=-lkvm
+endif
+
all:: $(TARGETS)
busy: busy.c $(LIBS)
$(CC) -o busy busy.c $(LIBS) $(CFLAGS)
+process_iterator_test: process_iterator_test.c $(LIBS)
+ $(CC) -I../src -o process_iterator_test process_iterator_test.c ../src/process_iterator.o $(LIBS) $(CFLAGS)
+
clean:
rm -f *~ *.o $(TARGETS)
diff --git a/tests/busy b/tests/busy
index c3a9aab..45aa93b 100755
--- a/tests/busy
+++ b/tests/busy
Binary files differ
diff --git a/tests/process_iterator_test b/tests/process_iterator_test
new file mode 100755
index 0000000..979cf89
--- /dev/null
+++ b/tests/process_iterator_test
Binary files differ
diff --git a/tests/process_iterator_test.c b/tests/process_iterator_test.c
new file mode 100644
index 0000000..080195a
--- /dev/null
+++ b/tests/process_iterator_test.c
@@ -0,0 +1,18 @@
+#include <stdio.h>
+#include <process_iterator.h>
+
+int main()
+{
+ struct process_iterator it;
+ struct process process;
+ init_process_iterator(&it);
+ while (read_next_process(&it, &process) != -1)
+ {
+ printf("Read process %d\n", process.pid);
+ printf("Parent %d\n", process.ppid);
+// printf("Starttime %d\n", process.starttime);
+ printf("Jiffies %d\n", process.last_jiffies);
+ }
+ close_process_iterator(&it);
+ return 0;
+}
Un proyecto texto-plano.xyz