first hack at the event queue.
This commit is contained in:
parent
f1dbd880a7
commit
3b91895093
4 changed files with 223 additions and 1 deletions
|
|
@ -31,7 +31,7 @@ inotify :
|
|||
../src/fs/notify_event.c \
|
||||
../src/fs/inotify.c \
|
||||
t_inotify.c -o test_inotify
|
||||
|
||||
|
||||
tree :
|
||||
$(CC) $(CFLAGS) $(DEFS) ../src/common/path.c ../src/fs/tree.c t_tree.c -o test_tree
|
||||
|
||||
|
|
@ -41,3 +41,6 @@ indexer :
|
|||
mysql :
|
||||
$(CC) -D DB_DEBUG $(CFLAGS) ../src/mysql_db.c -L/usr/lib64/mysql \
|
||||
-lmysqlclient -lz -lcrypt -lnsl -lm -L/usr/lib64 -lssl -lcrypto t_mysql.c -o test_mysql
|
||||
|
||||
queue :
|
||||
$(CC) $(CFLAGS) ../src/fs/queue.c t_queue.c -o test_queue
|
||||
|
|
|
|||
31
test/t_queue.c
Normal file
31
test/t_queue.c
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include "../src/fs/queue.h"
|
||||
|
||||
int main() {
|
||||
|
||||
int i, map[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
queue_t *q = init_queue();
|
||||
|
||||
for(i=0; i < 10; i++)
|
||||
queue_enqueue(q, &map[i]);
|
||||
|
||||
assert(queue_num_items(q) == 10);
|
||||
|
||||
for(i=0; i < 4; i++) {
|
||||
int *c = queue_dequeue(q);
|
||||
|
||||
if (c == NULL)
|
||||
continue;
|
||||
|
||||
assert(c == &map[i]);
|
||||
}
|
||||
|
||||
for(i=4; i < 10; i++)
|
||||
queue_enqueue(q, &map[i]);
|
||||
|
||||
queue_destroy(q);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in a new issue