2 * This file is part of buxton.
4 * Copyright (C) 2013 Intel Corporation
6 * buxton is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as
8 * published by the Free Software Foundation; either version 2.1
9 * of the License, or (at your option) any later version.
21 #include <sys/types.h>
30 #include "buxtonresponse.h"
31 #include "configurator.h"
32 #include "check_utils.h"
41 #error "re-run configure with --enable-debug"
44 #define BUXTON_ROOT_CHECK_ENV "BUXTON_ROOT_CHECK"
46 static pid_t daemon_pid;
49 typedef struct _fuzz_context_t {
55 static bool use_smack(void)
57 bool __attribute__((unused))dummy;
59 dummy = buxton_cache_smack_rules();
61 return buxton_smack_enabled();
64 static char* dump_fuzz(FuzzContext *fuzz)
72 s = open_memstream(&buf, &buff_size);
74 fprintf(s, "\n\n******************************************\n");
75 fprintf(s, "current time %ld\n", time(NULL));
76 fprintf(s, "iteration: %d\tsize: %llu\n", fuzz->iteration, (unsigned long long)fuzz->size);
77 for (int i = 0; i < fuzz->size; i++) {
78 fprintf(s, "%02X ", fuzz->buf[i]);
91 static void check_did_not_crash(pid_t pid, FuzzContext *fuzz)
96 rpid = waitpid(pid, &status, WNOHANG);
97 fail_if(rpid == -1, "couldn't wait for pid %m");
99 /* child is still running */
102 fail_if(WIFEXITED(status), "daemon exited with status %d%s",
103 WEXITSTATUS(status), dump_fuzz(fuzz));
104 fail_if(WIFSIGNALED(status), "daemon was killed with signal %d%s",
105 WTERMSIG(status), dump_fuzz(fuzz));
108 static void exec_daemon(void)
112 //FIXME: path is wrong for makedistcheck
113 snprintf(path, PATH_MAX, "%s/check_buxtond", get_current_dir_name());
115 if (execl(path, "check_buxtond", (const char*)NULL) < 0) {
116 fail("couldn't exec: %m");
118 fail("should never reach here");
121 static void setup(void)
127 unlink(buxton_socket());
129 sigemptyset(&sigset);
130 sigaddset(&sigset, SIGCHLD);
131 sigprocmask(SIG_BLOCK, &sigset, NULL);
134 fail_if(pid < 0, "couldn't fork");
145 static void teardown(void)
151 pid = waitpid(daemon_pid, &status, WNOHANG);
152 fail_if(pid == -1, "waitpid error");
154 fail("daemon crashed!");
156 /* if the daemon is still running, kill it */
157 kill(SIGTERM, daemon_pid);
159 kill(SIGKILL, daemon_pid);
164 START_TEST(buxton_open_check)
166 BuxtonClient c = NULL;
167 fail_if(buxton_open(&c) == -1,
168 "Connection failed to open with daemon.");
172 static void client_create_group_test(BuxtonResponse response, void *data)
174 char *k = (char *)data;
177 uid_t uid = getuid();
178 char *root_check = getenv(BUXTON_ROOT_CHECK_ENV);
179 bool skip_check = (root_check && streq(root_check, "0"));
181 fail_if(buxton_response_type(response) != BUXTON_CONTROL_CREATE_GROUP,
182 "Failed to get create group response type");
185 fail_if(buxton_response_status(response) != 0,
186 "Create group failed");
187 key = buxton_response_key(response);
188 fail_if(!key, "Failed to get create group key");
189 group = buxton_key_get_group(key);
190 fail_if(!group, "Failed to get group from key");
191 fail_if(!streq(group, k),
192 "Incorrect set key returned");
194 buxton_key_free(key);
196 fail_if(buxton_response_status(response) == 0 && !skip_check,
197 "Create group succeeded, but the client is not root");
200 START_TEST(buxton_create_group_check)
203 BuxtonKey key = buxton_key_create("tgroup", NULL, "base", STRING);
204 fail_if(!key, "Failed to create key");
205 fail_if(buxton_open(&c) == -1,
206 "Open failed with daemon.");
207 fail_if(buxton_create_group(c, key, client_create_group_test,
209 "Creating group in buxton failed.");
210 buxton_key_free(key);
214 static void client_remove_group_test(BuxtonResponse response, void *data)
216 char *k = (char *)data;
219 uid_t uid = getuid();
220 char *root_check = getenv(BUXTON_ROOT_CHECK_ENV);
221 bool skip_check = (root_check && streq(root_check, "0"));
223 fail_if(buxton_response_type(response) != BUXTON_CONTROL_REMOVE_GROUP,
224 "Failed to get remove group response type");
227 fail_if(buxton_response_status(response) != 0,
228 "Remove group failed");
229 key = buxton_response_key(response);
230 fail_if(!key, "Failed to get create group key");
231 group = buxton_key_get_group(key);
232 fail_if(!group, "Failed to get group from key");
233 fail_if(!streq(group, k),
234 "Incorrect set key returned");
236 buxton_key_free(key);
238 fail_if(buxton_response_status(response) == 0 && !skip_check,
239 "Create group succeeded, but the client is not root");
242 START_TEST(buxton_remove_group_check)
245 BuxtonKey key = buxton_key_create("tgroup", NULL, "base", STRING);
246 fail_if(!key, "Failed to create key");
247 fail_if(buxton_open(&c) == -1,
248 "Open failed with daemon.");
249 fail_if(buxton_remove_group(c, key, client_remove_group_test,
251 "Removing group in buxton failed.");
252 buxton_key_free(key);
256 static void client_set_value_test(BuxtonResponse response, void *data)
258 char *k = (char *)data;
262 fail_if(buxton_response_type(response) != BUXTON_CONTROL_SET,
263 "Failed to get set response type");
264 fail_if(buxton_response_status(response) != 0,
266 key = buxton_response_key(response);
267 fail_if(!key, "Failed to get set key");
268 group = buxton_key_get_group(key);
269 fail_if(!group, "Failed to get group from key");
270 fail_if(!streq(group, k),
271 "Incorrect set group returned");
273 buxton_key_free(key);
275 START_TEST(buxton_set_value_check)
278 BuxtonKey group = buxton_key_create("group", NULL, "test-gdbm-user", STRING);
279 fail_if(!group, "Failed to create key for group");
280 BuxtonKey key = buxton_key_create("group", "name", "test-gdbm-user", STRING);
281 fail_if(!key, "Failed to create key");
282 fail_if(buxton_open(&c) == -1,
283 "Open failed with daemon.");
284 fail_if(buxton_create_group(c, group, NULL, NULL, true),
285 "Creating group in buxton failed.");
286 fail_if(buxton_set_label(c, group, "*", NULL, NULL, true),
287 "Setting group in buxton failed.");
288 fail_if(buxton_set_value(c, key, "bxt_test_value",
289 client_set_value_test,
291 "Setting value in buxton failed.");
292 buxton_key_free(group);
293 buxton_key_free(key);
297 static void client_set_label_test(BuxtonResponse response, void *data)
299 BuxtonKey user_key = (BuxtonKey)data;
301 char *user_group, *group;
302 char *user_name, *name;
303 uid_t uid = getuid();
304 char *root_check = getenv(BUXTON_ROOT_CHECK_ENV);
305 bool skip_check = (root_check && streq(root_check, "0"));
307 fail_if(buxton_response_type(response) != BUXTON_CONTROL_SET_LABEL,
308 "Failed to get set label response type");
311 fail_if(buxton_response_status(response) != 0,
313 key = buxton_response_key(response);
314 fail_if(!key, "Failed to get set label key");
315 user_group = buxton_key_get_group(user_key);
316 fail_if(!user_group, "Failed to get group from user key");
317 group = buxton_key_get_group(key);
318 fail_if(!group, "Failed to get group from key");
319 fail_if(!streq(group, user_group),
320 "Incorrect set label group returned");
324 user_name = buxton_key_get_name(user_key);
326 name = buxton_key_get_name(key);
327 fail_if(!name, "Failed to get name from key");
328 fail_if(!streq(name, user_name),
329 "Incorrect set label name returned");
333 buxton_key_free(key);
336 fail_if(buxton_response_status(response) != 0,
339 fail_if(buxton_response_status(response) == 0,
340 "Set label succeeded, but the client is not root");
344 START_TEST(buxton_set_label_check)
347 BuxtonKey group = buxton_key_create("bxt_group", NULL, "test-gdbm", STRING);
348 fail_if(!group, "Failed to create key for group");
349 fail_if(buxton_open(&c) == -1,
350 "Open failed with daemon.");
351 fail_if(buxton_create_group(c, group, NULL, NULL, true),
352 "Creating group in buxton failed.");
353 fail_if(buxton_set_label(c, group, "*",
354 client_set_label_test,
356 "Setting label for group in buxton failed.");
358 BuxtonKey name = buxton_key_create("bxt_group", "bxt_name", "test-gdbm", STRING);
359 fail_if(!name, "Failed to create key for name");
360 fail_if(buxton_set_value(c, name, "bxt_value", NULL, NULL, true),
361 "Setting label for name in buxton failed.");
362 fail_if(buxton_set_label(c, name, "*",
363 client_set_label_test,
365 "Setting label for name in buxton failed.");
367 buxton_key_free(group);
368 buxton_key_free(name);
372 static void client_get_value_test(BuxtonResponse response, void *data)
378 char *value = (char *)data;
380 fail_if(buxton_response_status(response) != 0,
383 key = buxton_response_key(response);
384 fail_if(!key, "Failed to get key");
385 group = buxton_key_get_group(key);
386 fail_if(!group, "Failed to get group");
387 fail_if(!streq(group, "group"),
388 "Failed to get correct group");
389 name = buxton_key_get_name(key);
390 fail_if(!name, "Failed to get name");
391 fail_if(!streq(name, "name"),
392 "Failed to get correct name");
393 v = buxton_response_value(response);
394 printf("val=%s\n", v);
395 fail_if(!v, "Failed to get value");
396 fail_if(!streq(v, value),
397 "Failed to get correct value");
402 buxton_key_free(key);
404 START_TEST(buxton_get_value_for_layer_check)
406 BuxtonClient c = NULL;
407 BuxtonKey key = buxton_key_create("group", "name", "test-gdbm-user", STRING);
409 fail_if(buxton_open(&c) == -1,
410 "Open failed with daemon.");
411 fail_if(buxton_get_value(c, key,
412 client_get_value_test,
413 "bxt_test_value", true),
414 "Retrieving value from buxton gdbm backend failed.");
418 START_TEST(buxton_get_value_check)
420 BuxtonClient c = NULL;
422 BuxtonKey group = buxton_key_create("group", NULL, "test-gdbm", STRING);
423 fail_if(!group, "Failed to create key for group");
424 BuxtonKey key = buxton_key_create("group", "name", "test-gdbm", STRING);
426 fail_if(buxton_open(&c) == -1,
427 "Open failed with daemon.");
429 fail_if(buxton_create_group(c, group, NULL, NULL, true),
430 "Creating group in buxton failed.");
431 fail_if(buxton_set_label(c, group, "*", NULL, NULL, true),
432 "Setting group in buxton failed.");
433 fail_if(buxton_set_value(c, key, "bxt_test_value2",
434 client_set_value_test, "group", true),
435 "Failed to set second value.");
436 buxton_key_free(group);
437 buxton_key_free(key);
438 key = buxton_key_create("group", "name", NULL, STRING);
439 fail_if(buxton_get_value(c, key,
440 client_get_value_test,
441 "bxt_test_value2", true),
442 "Retrieving value from buxton gdbm backend failed.");
443 buxton_key_free(key);
447 START_TEST(parse_list_check)
453 BuxtonData *value = NULL;
455 fail_if(parse_list(BUXTON_CONTROL_NOTIFY, 2, l1, &key, &value),
456 "Parsed bad notify argument count");
460 fail_if(parse_list(BUXTON_CONTROL_NOTIFY, 3, l1, &key, &value),
461 "Parsed bad notify type 1");
465 fail_if(parse_list(BUXTON_CONTROL_NOTIFY, 3, l1, &key, &value),
466 "Parsed bad notify type 3");
470 fail_if(parse_list(BUXTON_CONTROL_NOTIFY, 3, l1, &key, &value),
471 "Parsed bad notify type 3");
475 l1[0].store.d_string = buxton_string_pack("s1");
476 l1[1].store.d_string = buxton_string_pack("s2");
477 l1[2].store.d_uint32 = STRING;
478 fail_if(!parse_list(BUXTON_CONTROL_NOTIFY, 3, l1, &key, &value),
479 "Unable to parse valid notify");
480 fail_if(!streq(key.group.value, l1[0].store.d_string.value),
481 "Failed to set correct notify group");
482 fail_if(!streq(key.name.value, l1[1].store.d_string.value),
483 "Failed to set correct notify name");
484 fail_if(key.type != l1[2].store.d_uint32,
485 "Failed to set correct notify type");
487 fail_if(parse_list(BUXTON_CONTROL_UNNOTIFY, 2, l1, &key, &value),
488 "Parsed bad unnotify argument count");
492 fail_if(parse_list(BUXTON_CONTROL_UNNOTIFY, 1, l1, &key, &value),
493 "Parsed bad unnotify type 1");
497 fail_if(parse_list(BUXTON_CONTROL_UNNOTIFY, 1, l1, &key, &value),
498 "Parsed bad unnotify type 2");
502 fail_if(parse_list(BUXTON_CONTROL_UNNOTIFY, 1, l1, &key, &value),
503 "Parsed bad unnotify type 3");
507 l1[0].store.d_string = buxton_string_pack("s3");
508 l1[1].store.d_string = buxton_string_pack("s4");
509 l1[2].store.d_uint32 = STRING;
510 fail_if(!parse_list(BUXTON_CONTROL_UNNOTIFY, 3, l1, &key, &value),
511 "Unable to parse valid unnotify");
512 fail_if(!streq(key.group.value, l1[0].store.d_string.value),
513 "Failed to set correct unnotify group");
514 fail_if(!streq(key.name.value, l1[1].store.d_string.value),
515 "Failed to set correct unnotify name");
516 fail_if(key.type != l1[2].store.d_uint32,
517 "Failed to set correct unnotify type");
519 fail_if(parse_list(BUXTON_CONTROL_GET, 5, l2, &key, &value),
520 "Parsed bad get argument count");
525 fail_if(parse_list(BUXTON_CONTROL_GET, 2, l2, &key, &value),
526 "Parsed bad get type 1");
531 fail_if(parse_list(BUXTON_CONTROL_GET, 2, l2, &key, &value),
532 "Parsed bad get type 2");
535 l2[2].type = BOOLEAN;
537 fail_if(parse_list(BUXTON_CONTROL_GET, 2, l2, &key, &value),
538 "Parsed bad get type 3");
543 fail_if(parse_list(BUXTON_CONTROL_GET, 2, l2, &key, &value),
544 "Parsed bad get type 4");
549 l2[0].store.d_string = buxton_string_pack("s5");
550 l2[1].store.d_string = buxton_string_pack("s6");
551 l2[2].store.d_string = buxton_string_pack("s7");
552 l2[3].store.d_uint32 = STRING;
553 fail_if(!parse_list(BUXTON_CONTROL_GET, 4, l2, &key, &value),
554 "Unable to parse valid get 1");
555 fail_if(!streq(key.layer.value, l2[0].store.d_string.value),
556 "Failed to set correct get layer 1");
557 fail_if(!streq(key.group.value, l2[1].store.d_string.value),
558 "Failed to set correct get group 1");
559 fail_if(!streq(key.name.value, l2[2].store.d_string.value),
560 "Failed to set correct get name");
561 fail_if(key.type != l2[3].store.d_uint32,
562 "Failed to set correct get type 1");
563 l2[0].store.d_string = buxton_string_pack("s6");
564 l2[1].store.d_string = buxton_string_pack("s6");
566 l2[2].store.d_uint32 = STRING;
567 fail_if(!parse_list(BUXTON_CONTROL_GET, 3, l2, &key, &value),
568 "Unable to parse valid get 2");
569 fail_if(!streq(key.group.value, l2[0].store.d_string.value),
570 "Failed to set correct get group 2");
571 fail_if(!streq(key.name.value, l2[1].store.d_string.value),
572 "Failed to set correct get name 2");
573 fail_if(key.type != l2[2].store.d_uint32,
574 "Failed to set correct get type 2");
576 fail_if(parse_list(BUXTON_CONTROL_SET, 1, l2, &key, &value),
577 "Parsed bad set argument count");
582 fail_if(parse_list(BUXTON_CONTROL_SET, 3, l2, &key, &value),
583 "Parsed bad set type 1");
588 fail_if(parse_list(BUXTON_CONTROL_SET, 3, l2, &key, &value),
589 "Parsed bad set type 2");
592 l2[2].type = BOOLEAN;
594 fail_if(parse_list(BUXTON_CONTROL_SET, 3, l2, &key, &value),
595 "Parsed bad set type 3");
600 l2[0].store.d_string = buxton_string_pack("s8");
601 l2[1].store.d_string = buxton_string_pack("s9");
602 l2[2].store.d_string = buxton_string_pack("s10");
603 l2[3].store.d_float = 3.14F;
604 fail_if(!parse_list(BUXTON_CONTROL_SET, 4, l2, &key, &value),
605 "Unable to parse valid set 1");
606 fail_if(!streq(key.layer.value, l2[0].store.d_string.value),
607 "Failed to set correct set layer 1");
608 fail_if(!streq(key.group.value, l2[1].store.d_string.value),
609 "Failed to set correct set group 1");
610 fail_if(!streq(key.name.value, l2[2].store.d_string.value),
611 "Failed to set correct set name 1");
612 fail_if(value->store.d_float != l2[3].store.d_float,
613 "Failed to set correct set value 1");
615 fail_if(parse_list(BUXTON_CONTROL_UNSET, 1, l2, &key, &value),
616 "Parsed bad unset argument count");
621 fail_if(parse_list(BUXTON_CONTROL_UNSET, 4, l2, &key, &value),
622 "Parsed bad unset type 1");
627 fail_if(parse_list(BUXTON_CONTROL_UNSET, 4, l2, &key, &value),
628 "Parsed bad unset type 2");
631 l2[2].type = BOOLEAN;
633 fail_if(parse_list(BUXTON_CONTROL_UNSET, 4, l2, &key, &value),
634 "Parsed bad unset type 3");
639 fail_if(parse_list(BUXTON_CONTROL_UNSET, 4, l2, &key, &value),
640 "Parsed bad unset type 4");
645 l2[0].store.d_string = buxton_string_pack("s11");
646 l2[1].store.d_string = buxton_string_pack("s12");
647 l2[2].store.d_string = buxton_string_pack("s13");
648 l2[3].store.d_uint32 = STRING;
649 fail_if(!parse_list(BUXTON_CONTROL_UNSET, 4, l2, &key, &value),
650 "Unable to parse valid unset 1");
651 fail_if(!streq(key.layer.value, l2[0].store.d_string.value),
652 "Failed to set correct unset layer 1");
653 fail_if(!streq(key.group.value, l2[1].store.d_string.value),
654 "Failed to set correct unset group 1");
655 fail_if(!streq(key.name.value, l2[2].store.d_string.value),
656 "Failed to set correct unset name 1");
657 fail_if(key.type != l2[3].store.d_uint32,
658 "Failed to set correct unset type 1");
660 fail_if(parse_list(BUXTON_CONTROL_SET_LABEL, 1, l2, &key, &value),
661 "Parsed bad set label argument count");
665 fail_if(parse_list(BUXTON_CONTROL_SET_LABEL, 3, l1, &key, &value),
666 "Parsed bad set label type 1");
670 fail_if(parse_list(BUXTON_CONTROL_SET_LABEL, 3, l1, &key, &value),
671 "Parsed bad set label type 2");
674 l1[2].type = BOOLEAN;
675 fail_if(parse_list(BUXTON_CONTROL_SET_LABEL, 3, l1, &key, &value),
676 "Parsed bad set label type 3");
680 l1[0].store.d_string = buxton_string_pack("s14");
681 l1[1].store.d_string = buxton_string_pack("s15");
682 l1[2].store.d_string = buxton_string_pack("*");
683 fail_if(!parse_list(BUXTON_CONTROL_SET_LABEL, 3, l1, &key, &value),
684 "Unable to parse valid set label 1");
685 fail_if(!streq(key.layer.value, l1[0].store.d_string.value),
686 "Failed to set correct set label layer 1");
687 fail_if(!streq(key.group.value, l1[1].store.d_string.value),
688 "Failed to set correct set label group 1");
689 fail_if(!streq(value->store.d_string.value, l1[2].store.d_string.value),
690 "Failed to set correct set label label 1");
691 fail_if(key.type != STRING, "Failed to key type in set label");
693 fail_if(parse_list(BUXTON_CONTROL_CREATE_GROUP, 1, l3, &key, &value),
694 "Parsed bad create group argument count");
697 fail_if(parse_list(BUXTON_CONTROL_SET_LABEL, 2, l3, &key, &value),
698 "Parsed bad create group type 1");
701 fail_if(parse_list(BUXTON_CONTROL_SET_LABEL, 2, l3, &key, &value),
702 "Parsed bad create group type 2");
705 l3[0].store.d_string = buxton_string_pack("s16");
706 l3[1].store.d_string = buxton_string_pack("s17");
707 fail_if(!parse_list(BUXTON_CONTROL_CREATE_GROUP, 2, l3, &key, &value),
708 "Unable to parse valid create group 1");
709 fail_if(!streq(key.layer.value, l3[0].store.d_string.value),
710 "Failed to set correct create group layer 1");
711 fail_if(!streq(key.group.value, l3[1].store.d_string.value),
712 "Failed to set correct create group group 1");
713 fail_if(key.type != STRING, "Failed to key type in create group");
715 fail_if(parse_list(BUXTON_CONTROL_REMOVE_GROUP, 1, l3, &key, &value),
716 "Parsed bad remove group argument count");
719 fail_if(parse_list(BUXTON_CONTROL_SET_LABEL, 2, l3, &key, &value),
720 "Parsed bad remove group type 1");
723 fail_if(parse_list(BUXTON_CONTROL_SET_LABEL, 2, l3, &key, &value),
724 "Parsed bad remove group type 2");
727 l3[0].store.d_string = buxton_string_pack("s18");
728 l3[1].store.d_string = buxton_string_pack("s19");
729 fail_if(!parse_list(BUXTON_CONTROL_REMOVE_GROUP, 2, l3, &key, &value),
730 "Unable to parse valid remove group 1");
731 fail_if(!streq(key.layer.value, l3[0].store.d_string.value),
732 "Failed to set correct remove group layer 1");
733 fail_if(!streq(key.group.value, l3[1].store.d_string.value),
734 "Failed to set correct remove group group 1");
735 fail_if(key.type != STRING, "Failed to key type in remove group");
739 START_TEST(create_group_check)
741 _BuxtonKey key = { {0}, {0}, {0}, 0};
742 client_list_item client;
745 BuxtonString clabel = buxton_string_pack("_");
747 fail_if(!buxton_direct_open(&server.buxton),
748 "Failed to open buxton direct connection");
750 client.cred.uid = getuid();
752 client.smack_label = &clabel;
754 client.smack_label = NULL;
755 server.buxton.client.uid = 0;
757 key.layer = buxton_string_pack("test-gdbm-user");
758 key.group = buxton_string_pack("daemon-check");
760 create_group(&server, &client, &key, &status);
761 fail_if(status != 0, "Failed to create group");
763 key.layer = buxton_string_pack("test-gdbm");
764 create_group(&server, &client, &key, &status);
765 fail_if(status != 0, "Failed to create group");
767 key.layer = buxton_string_pack("base");
768 key.group = buxton_string_pack("tgroup");
769 create_group(&server, &client, &key, &status);
770 fail_if(status != 0, "Failed to create group");
772 buxton_direct_close(&server.buxton);
776 START_TEST(remove_group_check)
778 _BuxtonKey key = { {0}, {0}, {0}, 0};
779 client_list_item client;
782 BuxtonString clabel = buxton_string_pack("_");
784 fail_if(!buxton_direct_open(&server.buxton),
785 "Failed to open buxton direct connection");
787 client.cred.uid = getuid();
789 client.smack_label = &clabel;
791 client.smack_label = NULL;
792 server.buxton.client.uid = 0;
794 key.layer = buxton_string_pack("base");
795 key.group = buxton_string_pack("tgroup");
798 remove_group(&server, &client, &key, &status);
799 fail_if(status != 0, "Failed to remove group");
801 buxton_direct_close(&server.buxton);
805 START_TEST(set_label_check)
807 _BuxtonKey key = { {0}, {0}, {0}, 0};
809 client_list_item client;
812 BuxtonString clabel = buxton_string_pack("_");
814 fail_if(!buxton_direct_open(&server.buxton),
815 "Failed to open buxton direct connection");
817 client.cred.uid = getuid();
819 client.smack_label = &clabel;
821 client.smack_label = NULL;
822 server.buxton.client.uid = 0;
823 key.layer = buxton_string_pack("test-gdbm-user");
824 key.group = buxton_string_pack("daemon-check");
827 value.store.d_string = buxton_string_pack("*");
829 key.layer = buxton_string_pack("test-gdbm");
830 set_label(&server, &client, &key, &value, &status);
831 fail_if(status != 0, "Failed to set label 2");
832 buxton_direct_close(&server.buxton);
836 START_TEST(set_value_check)
838 _BuxtonKey key = { {0}, {0}, {0}, 0};
840 client_list_item client;
843 BuxtonString clabel = buxton_string_pack("_");
845 fail_if(!buxton_direct_open(&server.buxton),
846 "Failed to open buxton direct connection");
848 client.cred.uid = getuid();
849 server.buxton.client.uid = 0;
852 client.smack_label = &clabel;
854 client.smack_label = NULL;
856 key.layer = buxton_string_pack("test-gdbm-user");
857 key.group = buxton_string_pack("daemon-check");
858 key.name = buxton_string_pack("name");
860 value.store.d_string = buxton_string_pack("user-layer-value");
862 set_value(&server, &client, &key, &value, &status);
863 fail_if(status != 0, "Failed to set value");
864 fail_if(server.buxton.client.uid != client.cred.uid, "Failed to change buxton uid");
866 key.layer = buxton_string_pack("test-gdbm");
867 value.store.d_string = buxton_string_pack("system-layer-value");
868 set_value(&server, &client, &key, &value, &status);
869 fail_if(status != 0, "Failed to set value");
871 buxton_direct_close(&server.buxton);
875 START_TEST(get_value_check)
877 _BuxtonKey key = { {0}, {0}, {0}, 0};
879 client_list_item client;
882 BuxtonString clabel = buxton_string_pack("_");
884 fail_if(!buxton_direct_open(&server.buxton),
885 "Failed to open buxton direct connection");
887 fail_if(!buxton_cache_smack_rules(),
888 "Failed to cache smack rules");
889 client.cred.uid = getuid();
891 client.smack_label = &clabel;
893 client.smack_label = NULL;
894 server.buxton.client.uid = 0;
895 key.layer = buxton_string_pack("test-gdbm-user");
896 key.group = buxton_string_pack("daemon-check");
897 key.name = buxton_string_pack("name");
900 value = get_value(&server, &client, &key, &status);
901 fail_if(!value, "Failed to get value");
902 fail_if(status != 0, "Failed to get value");
903 fail_if(value->type != STRING, "Failed to get correct type");
904 fail_if(!streq(value->store.d_string.value, "user-layer-value"), "Failed to get correct value");
905 fail_if(server.buxton.client.uid != client.cred.uid, "Failed to change buxton uid");
908 server.buxton.client.uid = 0;
909 key.layer.value = NULL;
910 key.layer.length = 0;
911 value = get_value(&server, &client, &key, &status);
912 fail_if(!value, "Failed to get value 2");
913 fail_if(status != 0, "Failed to get value 2");
914 fail_if(value->type != STRING, "Failed to get correct type 2");
915 fail_if(!streq(value->store.d_string.value, "system-layer-value"), "Failed to get correct value 2");
916 fail_if(server.buxton.client.uid != client.cred.uid, "Failed to change buxton uid 2");
919 buxton_direct_close(&server.buxton);
923 START_TEST(register_notification_check)
925 _BuxtonKey key = { {0}, {0}, {0}, 0};
926 client_list_item client, no_client;
927 BuxtonString clabel = buxton_string_pack("_");
932 fail_if(!buxton_cache_smack_rules(),
933 "Failed to cache smack rules");
935 client.smack_label = &clabel;
937 client.smack_label = NULL;
938 client.cred.uid = 1002;
939 fail_if(!buxton_direct_open(&server.buxton),
940 "Failed to open buxton direct connection");
941 server.notify_mapping = hashmap_new(string_hash_func, string_compare_func);
942 fail_if(!server.notify_mapping, "Failed to allocate hashmap");
944 key.group = buxton_string_pack("group");
945 key.name = buxton_string_pack("name");
947 register_notification(&server, &client, &key, 1, &status);
948 fail_if(status != 0, "Failed to register notification");
949 register_notification(&server, &client, &key, 1, &status);
950 fail_if(status != 0, "Failed to register notification");
951 //FIXME: Figure out what to do with duplicates
952 key.group = buxton_string_pack("no-key");
953 msgid = unregister_notification(&server, &client, &key, &status);
955 "Unregistered from notifications with invalid key");
956 fail_if(msgid != 0, "Got unexpected notify message id");
957 key.group = buxton_string_pack("group");
958 msgid = unregister_notification(&server, &no_client, &key, &status);
960 "Unregistered from notifications with invalid client");
961 fail_if(msgid != 0, "Got unexpected notify message id");
962 msgid = unregister_notification(&server, &client, &key, &status);
964 "Unable to unregister from notifications");
965 fail_if(msgid != 1, "Failed to get correct notify message id");
966 key.group = buxton_string_pack("key2");
967 register_notification(&server, &client, &key, 0, &status);
968 fail_if(status == 0, "Registered notification with key not in db");
970 hashmap_free(server.notify_mapping);
971 buxton_direct_close(&server.buxton);
974 START_TEST(buxtond_handle_message_error_check)
983 BuxtonArray *list = NULL;
986 setup_socket_pair(&client, &server);
987 fail_if(fcntl(client, F_SETFL, O_NONBLOCK),
988 "Failed to set socket to non blocking");
989 fail_if(fcntl(server, F_SETFL, O_NONBLOCK),
990 "Failed to set socket to non blocking");
991 list = buxton_array_new();
992 fail_if(!list, "Failed to allocate list");
995 slabel = buxton_string_pack("_");
996 cl.smack_label = &slabel;
997 daemon.buxton.client.uid = 1001;
998 fail_if(!buxton_cache_smack_rules(), "Failed to cache Smack rules");
999 fail_if(!buxton_direct_open(&daemon.buxton),
1000 "Failed to open buxton direct connection");
1002 cl.data = malloc(4);
1003 fail_if(!cl.data, "Couldn't allocate blank message");
1009 r = buxtond_handle_message(&daemon, &cl, size);
1010 fail_if(r, "Failed to detect invalid message data");
1013 data1.type = STRING;
1014 data1.store.d_string = buxton_string_pack("group");
1015 r = buxton_array_add(list, &data1);
1016 fail_if(!r, "Failed to add element to array");
1017 size = buxton_serialize_message(&cl.data, BUXTON_CONTROL_NOTIFY, 0,
1019 fail_if(size == 0, "Failed to serialize message");
1020 control = BUXTON_CONTROL_MIN;
1021 memcpy(cl.data, &control, sizeof(uint16_t));
1022 r = buxtond_handle_message(&daemon, &cl, size);
1023 fail_if(r, "Failed to detect min control size");
1024 control = BUXTON_CONTROL_MAX;
1025 memcpy(cl.data, &control, sizeof(uint16_t));
1026 r = buxtond_handle_message(&daemon, &cl, size);
1028 fail_if(r, "Failed to detect max control size");
1031 buxton_direct_close(&daemon.buxton);
1032 buxton_array_free(&list, NULL);
1036 START_TEST(buxtond_handle_message_create_group_check)
1038 BuxtonDaemon daemon;
1039 BuxtonString slabel;
1041 BuxtonData data1, data2;
1042 client_list_item cl;
1045 BuxtonArray *out_list1, *out_list2;
1046 BuxtonControlMessage msg;
1053 setup_socket_pair(&client, &server);
1054 fail_if(fcntl(client, F_SETFL, O_NONBLOCK),
1055 "Failed to set socket to non blocking");
1056 fail_if(fcntl(server, F_SETFL, O_NONBLOCK),
1057 "Failed to set socket to non blocking");
1060 slabel = buxton_string_pack("_");
1062 cl.smack_label = &slabel;
1064 cl.smack_label = NULL;
1066 daemon.buxton.client.uid = 1001;
1067 fail_if(!buxton_cache_smack_rules(), "Failed to cache Smack rules");
1068 fail_if(!buxton_direct_open(&daemon.buxton),
1069 "Failed to open buxton direct connection");
1070 daemon.notify_mapping = hashmap_new(string_hash_func, string_compare_func);
1071 fail_if(!daemon.notify_mapping, "Failed to allocate hashmap");
1073 out_list1 = buxton_array_new();
1074 fail_if(!out_list1, "Failed to allocate list");
1075 data1.type = STRING;
1076 data1.store.d_string = buxton_string_pack("base");
1077 data2.type = STRING;
1078 data2.store.d_string = buxton_string_pack("tgroup");
1079 r = buxton_array_add(out_list1, &data1);
1080 fail_if(!r, "Failed to add element to array");
1081 r = buxton_array_add(out_list1, &data2);
1082 fail_if(!r, "Failed to add element to array");
1084 size = buxton_serialize_message(&cl.data, BUXTON_CONTROL_CREATE_GROUP, 0,
1086 fail_if(size == 0, "Failed to serialize message");
1087 r = buxtond_handle_message(&daemon, &cl, size);
1089 fail_if(!r, "Failed to handle create group message");
1091 s = read(client, buf, 4096);
1092 fail_if(s < 0, "Read from client failed");
1093 csize = buxton_deserialize_message(buf, &msg, (size_t)s, &msgid, &list);
1094 fail_if(csize != 1, "Failed to get correct response to create group");
1095 fail_if(msg != BUXTON_CONTROL_STATUS,
1096 "Failed to get correct control type");
1097 fail_if(list[0].type != INT32,
1098 "Failed to get correct indicator type");
1099 fail_if(list[0].store.d_int32 != 0,
1100 "Failed to create group");
1101 fail_if(msgid != 0, "Failed to get correct message id");
1104 out_list2 = buxton_array_new();
1105 fail_if(!out_list2, "Failed to allocate list");
1106 data1.store.d_string = buxton_string_pack("base");
1107 data2.store.d_string = buxton_string_pack("daemon-check");
1108 r = buxton_array_add(out_list2, &data1);
1109 fail_if(!r, "Failed to add element to array");
1110 r = buxton_array_add(out_list2, &data2);
1111 fail_if(!r, "Failed to add element to array");
1113 size = buxton_serialize_message(&cl.data, BUXTON_CONTROL_CREATE_GROUP, 1,
1115 fail_if(size == 0, "Failed to serialize message");
1116 r = buxtond_handle_message(&daemon, &cl, size);
1118 fail_if(!r, "Failed to handle create group message");
1120 s = read(client, buf, 4096);
1121 fail_if(s < 0, "Read from client failed");
1122 csize = buxton_deserialize_message(buf, &msg, (size_t)s, &msgid, &list);
1123 fail_if(csize != 1, "Failed to get correct response to create group");
1124 fail_if(msg != BUXTON_CONTROL_STATUS,
1125 "Failed to get correct control type");
1126 fail_if(list[0].type != INT32,
1127 "Failed to get correct indicator type");
1128 fail_if(list[0].store.d_int32 != 0,
1129 "Failed to create group");
1130 fail_if(msgid != 1, "Failed to get correct message id");
1133 cleanup_callbacks();
1135 hashmap_free(daemon.notify_mapping);
1136 buxton_direct_close(&daemon.buxton);
1137 buxton_array_free(&out_list1, NULL);
1138 buxton_array_free(&out_list2, NULL);
1142 START_TEST(buxtond_handle_message_remove_group_check)
1144 BuxtonDaemon daemon;
1145 BuxtonString slabel;
1147 BuxtonData data1, data2;
1148 client_list_item cl;
1151 BuxtonArray *out_list;
1152 BuxtonControlMessage msg;
1159 setup_socket_pair(&client, &server);
1160 fail_if(fcntl(client, F_SETFL, O_NONBLOCK),
1161 "Failed to set socket to non blocking");
1162 fail_if(fcntl(server, F_SETFL, O_NONBLOCK),
1163 "Failed to set socket to non blocking");
1165 out_list = buxton_array_new();
1166 fail_if(!out_list, "Failed to allocate list");
1168 slabel = buxton_string_pack("_");
1170 cl.smack_label = &slabel;
1172 cl.smack_label = NULL;
1174 daemon.buxton.client.uid = 1001;
1175 fail_if(!buxton_cache_smack_rules(), "Failed to cache Smack rules");
1176 fail_if(!buxton_direct_open(&daemon.buxton),
1177 "Failed to open buxton direct connection");
1178 daemon.notify_mapping = hashmap_new(string_hash_func, string_compare_func);
1179 fail_if(!daemon.notify_mapping, "Failed to allocate hashmap");
1181 data1.type = STRING;
1182 data1.store.d_string = buxton_string_pack("base");
1183 data2.type = STRING;
1184 data2.store.d_string = buxton_string_pack("tgroup");
1185 r = buxton_array_add(out_list, &data1);
1186 fail_if(!r, "Failed to add element to array");
1187 r = buxton_array_add(out_list, &data2);
1188 fail_if(!r, "Failed to add element to array");
1190 size = buxton_serialize_message(&cl.data, BUXTON_CONTROL_REMOVE_GROUP, 0,
1192 fail_if(size == 0, "Failed to serialize message");
1193 r = buxtond_handle_message(&daemon, &cl, size);
1195 fail_if(!r, "Failed to handle remove group message");
1197 s = read(client, buf, 4096);
1198 fail_if(s < 0, "Read from client failed");
1199 csize = buxton_deserialize_message(buf, &msg, (size_t)s, &msgid, &list);
1200 fail_if(csize != 1, "Failed to get correct response to remove group");
1201 fail_if(msg != BUXTON_CONTROL_STATUS,
1202 "Failed to get correct control type");
1203 fail_if(list[0].type != INT32,
1204 "Failed to get correct indicator type");
1205 fail_if(list[0].store.d_int32 != 0,
1206 "Failed to remove group");
1207 fail_if(msgid != 0, "Failed to get correct message id");
1210 cleanup_callbacks();
1212 hashmap_free(daemon.notify_mapping);
1213 buxton_direct_close(&daemon.buxton);
1214 buxton_array_free(&out_list, NULL);
1218 START_TEST(buxtond_handle_message_set_label_check)
1220 BuxtonDaemon daemon;
1221 BuxtonString slabel;
1223 BuxtonData data1, data2, data3;
1224 client_list_item cl;
1227 BuxtonArray *out_list;
1228 BuxtonControlMessage msg;
1235 setup_socket_pair(&client, &server);
1236 fail_if(fcntl(client, F_SETFL, O_NONBLOCK),
1237 "Failed to set socket to non blocking");
1238 fail_if(fcntl(server, F_SETFL, O_NONBLOCK),
1239 "Failed to set socket to non blocking");
1241 out_list = buxton_array_new();
1242 fail_if(!out_list, "Failed to allocate list");
1244 slabel = buxton_string_pack("_");
1246 cl.smack_label = &slabel;
1248 cl.smack_label = NULL;
1250 daemon.buxton.client.uid = 1001;
1251 fail_if(!buxton_cache_smack_rules(), "Failed to cache Smack rules");
1252 fail_if(!buxton_direct_open(&daemon.buxton),
1253 "Failed to open buxton direct connection");
1254 daemon.notify_mapping = hashmap_new(string_hash_func, string_compare_func);
1255 fail_if(!daemon.notify_mapping, "Failed to allocate hashmap");
1257 data1.type = STRING;
1258 data1.store.d_string = buxton_string_pack("base");
1259 data2.type = STRING;
1260 data2.store.d_string = buxton_string_pack("daemon-check");
1261 data3.type = STRING;
1262 data3.store.d_string = buxton_string_pack("*");
1263 r = buxton_array_add(out_list, &data1);
1264 fail_if(!r, "Failed to add element to array");
1265 r = buxton_array_add(out_list, &data2);
1266 fail_if(!r, "Failed to add element to array");
1267 r = buxton_array_add(out_list, &data3);
1268 fail_if(!r, "Failed to add element to array");
1270 size = buxton_serialize_message(&cl.data, BUXTON_CONTROL_SET_LABEL, 0,
1272 fail_if(size == 0, "Failed to serialize message");
1273 r = buxtond_handle_message(&daemon, &cl, size);
1275 fail_if(!r, "Failed to handle set label message");
1277 s = read(client, buf, 4096);
1278 fail_if(s < 0, "Read from client failed");
1279 csize = buxton_deserialize_message(buf, &msg, (size_t)s, &msgid, &list);
1280 fail_if(csize != 1, "Failed to get correct response to set label");
1281 fail_if(msg != BUXTON_CONTROL_STATUS,
1282 "Failed to get correct control type");
1283 fail_if(list[0].type != INT32,
1284 "Failed to get correct indicator type");
1285 fail_if(list[0].store.d_int32 != 0,
1286 "Failed to set label");
1287 fail_if(msgid != 0, "Failed to get correct message id");
1290 cleanup_callbacks();
1292 hashmap_free(daemon.notify_mapping);
1293 buxton_direct_close(&daemon.buxton);
1294 buxton_array_free(&out_list, NULL);
1298 START_TEST(buxtond_handle_message_set_value_check)
1300 BuxtonDaemon daemon;
1301 BuxtonString slabel;
1303 BuxtonData data1, data2, data3, data4;
1304 client_list_item cl;
1307 BuxtonArray *out_list;
1308 BuxtonControlMessage msg;
1315 setup_socket_pair(&client, &server);
1316 fail_if(fcntl(client, F_SETFL, O_NONBLOCK),
1317 "Failed to set socket to non blocking");
1318 fail_if(fcntl(server, F_SETFL, O_NONBLOCK),
1319 "Failed to set socket to non blocking");
1321 out_list = buxton_array_new();
1322 fail_if(!out_list, "Failed to allocate list");
1324 slabel = buxton_string_pack("_");
1326 cl.smack_label = &slabel;
1328 cl.smack_label = NULL;
1330 daemon.buxton.client.uid = 1001;
1331 fail_if(!buxton_cache_smack_rules(), "Failed to cache Smack rules");
1332 fail_if(!buxton_direct_open(&daemon.buxton),
1333 "Failed to open buxton direct connection");
1334 daemon.notify_mapping = hashmap_new(string_hash_func, string_compare_func);
1335 fail_if(!daemon.notify_mapping, "Failed to allocate hashmap");
1337 data1.type = STRING;
1338 data1.store.d_string = buxton_string_pack("base");
1339 data2.type = STRING;
1340 data2.store.d_string = buxton_string_pack("daemon-check");
1341 data3.type = STRING;
1342 data3.store.d_string = buxton_string_pack("name");
1343 data4.type = STRING;
1344 data4.store.d_string = buxton_string_pack("bxt_test_value3");
1345 r = buxton_array_add(out_list, &data1);
1346 fail_if(!r, "Failed to add element to array");
1347 r = buxton_array_add(out_list, &data2);
1348 fail_if(!r, "Failed to add element to array");
1349 r = buxton_array_add(out_list, &data3);
1350 fail_if(!r, "Failed to add element to array");
1351 r = buxton_array_add(out_list, &data4);
1352 fail_if(!r, "Failed to add element to array");
1353 size = buxton_serialize_message(&cl.data, BUXTON_CONTROL_NOTIFY, 0,
1355 fail_if(size == 0, "Failed to serialize message");
1356 r = buxtond_handle_message(&daemon, &cl, size);
1358 fail_if(r, "Failed to detect parse_list failure");
1360 size = buxton_serialize_message(&cl.data, BUXTON_CONTROL_SET, 0,
1362 fail_if(size == 0, "Failed to serialize message");
1363 r = buxtond_handle_message(&daemon, &cl, size);
1365 fail_if(!r, "Failed to handle set message");
1367 s = read(client, buf, 4096);
1368 fail_if(s < 0, "Read from client failed");
1369 csize = buxton_deserialize_message(buf, &msg, (size_t)s, &msgid, &list);
1370 fail_if(csize != 1, "Failed to get correct response to set");
1371 fail_if(msg != BUXTON_CONTROL_STATUS,
1372 "Failed to get correct control type");
1373 fail_if(list[0].type != INT32,
1374 "Failed to get correct indicator type");
1375 fail_if(list[0].store.d_int32 != 0,
1377 fail_if(msgid != 0, "Failed to get correct message id");
1380 cleanup_callbacks();
1382 hashmap_free(daemon.notify_mapping);
1383 buxton_direct_close(&daemon.buxton);
1384 buxton_array_free(&out_list, NULL);
1388 START_TEST(buxtond_handle_message_get_check)
1391 BuxtonDaemon daemon;
1392 BuxtonString slabel;
1394 BuxtonData data1, data2, data3, data4;
1395 client_list_item cl;
1398 BuxtonArray *out_list;
1399 BuxtonArray *out_list2;
1400 BuxtonControlMessage msg;
1406 setup_socket_pair(&client, &server);
1407 out_list = buxton_array_new();
1408 fail_if(!out_list, "Failed to allocate list");
1411 slabel = buxton_string_pack("_");
1413 cl.smack_label = &slabel;
1415 cl.smack_label = NULL;
1416 cl.cred.uid = getuid();
1417 daemon.buxton.client.uid = 1001;
1418 fail_if(!buxton_cache_smack_rules(), "Failed to cache Smack rules");
1419 fail_if(!buxton_direct_open(&daemon.buxton),
1420 "Failed to open buxton direct connection");
1422 data1.type = STRING;
1423 data1.store.d_string = buxton_string_pack("test-gdbm-user");
1424 data2.type = STRING;
1425 data2.store.d_string = buxton_string_pack("daemon-check");
1426 data3.type = STRING;
1427 data3.store.d_string = buxton_string_pack("name");
1428 data4.type = UINT32;
1429 data4.store.d_uint32 = STRING;
1430 r = buxton_array_add(out_list, &data1);
1431 fail_if(!r, "Failed to add element to array");
1432 r = buxton_array_add(out_list, &data2);
1433 fail_if(!r, "Failed to add element to array");
1434 r = buxton_array_add(out_list, &data3);
1435 fail_if(!r, "Failed to add element to array");
1436 r = buxton_array_add(out_list, &data4);
1437 fail_if(!r, "Failed to add element to array");
1438 size = buxton_serialize_message(&cl.data, BUXTON_CONTROL_GET, 0,
1440 fail_if(size == 0, "Failed to serialize message");
1441 r = buxtond_handle_message(&daemon, &cl, size);
1443 fail_if(!r, "Failed to get message 1");
1445 s = read(client, buf, 4096);
1446 fail_if(s < 0, "Read from client failed");
1447 csize = buxton_deserialize_message(buf, &msg, (size_t)s, &msgid, &list);
1448 fail_if(csize != 2, "Failed to get valid message from buffer");
1449 fail_if(msg != BUXTON_CONTROL_STATUS,
1450 "Failed to get correct control type");
1451 fail_if(msgid != 0, "Failed to get correct message id");
1452 fail_if(list[0].type != INT32, "Failed to get correct response type");
1453 fail_if(list[0].store.d_int32 != 0,
1454 "Failed to get value");
1455 fail_if(list[1].type != STRING, "Failed to get correct value type");
1456 fail_if(!streq(list[1].store.d_string.value, "user-layer-value"),
1457 "Failed to get correct value");
1459 free(list[1].store.d_string.value);
1462 out_list2 = buxton_array_new();
1463 fail_if(!out_list2, "Failed to allocate list 2");
1464 r = buxton_array_add(out_list2, &data2);
1465 fail_if(!r, "Failed to add element to array 2");
1466 r = buxton_array_add(out_list2, &data3);
1467 fail_if(!r, "Failed to add element to array 2");
1468 r = buxton_array_add(out_list2, &data4);
1469 fail_if(!r, "Failed to add element to array 2");
1470 size = buxton_serialize_message(&cl.data, BUXTON_CONTROL_GET, 0,
1472 fail_if(size == 0, "Failed to serialize message 2");
1473 r = buxtond_handle_message(&daemon, &cl, size);
1475 fail_if(!r, "Failed to get message 2");
1477 s = read(client, buf, 4096);
1478 fail_if(s < 0, "Read from client failed 2");
1479 csize = buxton_deserialize_message(buf, &msg, (size_t)s, &msgid, &list);
1480 fail_if(csize != 2, "Failed to get correct response to get 2");
1481 fail_if(msg != BUXTON_CONTROL_STATUS,
1482 "Failed to get correct control type 2");
1483 fail_if(msgid != 0, "Failed to get correct message id 2");
1484 fail_if(list[0].type != INT32, "Failed to get correct response type 2");
1485 fail_if(list[0].store.d_int32 != 0,
1486 "Failed to get value 2");
1487 fail_if(list[1].type != STRING, "Failed to get correct value type 2");
1488 fail_if(streq(list[1].store.d_string.value, "bxt_test_value2"),
1489 "Failed to get correct value 2");
1491 free(list[1].store.d_string.value);
1494 buxton_direct_close(&daemon.buxton);
1495 buxton_array_free(&out_list, NULL);
1496 buxton_array_free(&out_list2, NULL);
1500 START_TEST(buxtond_handle_message_notify_check)
1503 BuxtonDaemon daemon;
1504 BuxtonString slabel;
1506 BuxtonData data1, data2, data3;
1507 client_list_item cl;
1510 BuxtonArray *out_list;
1511 BuxtonControlMessage msg;
1517 setup_socket_pair(&client, &server);
1518 out_list = buxton_array_new();
1519 fail_if(!out_list, "Failed to allocate list");
1522 slabel = buxton_string_pack("_");
1524 cl.smack_label = &slabel;
1526 cl.smack_label = NULL;
1528 daemon.buxton.client.uid = 1001;
1529 daemon.notify_mapping = hashmap_new(string_hash_func, string_compare_func);
1530 fail_if(!daemon.notify_mapping, "Failed to allocate hashmap");
1531 fail_if(!buxton_cache_smack_rules(), "Failed to cache Smack rules");
1532 fail_if(!buxton_direct_open(&daemon.buxton),
1533 "Failed to open buxton direct connection");
1535 data1.type = STRING;
1536 data1.store.d_string = buxton_string_pack("group");
1537 data2.type = STRING;
1538 data2.store.d_string = buxton_string_pack("name");
1539 data3.type = UINT32;
1540 data3.store.d_uint32 = STRING;
1541 r = buxton_array_add(out_list, &data1);
1542 fail_if(!r, "Failed to add element to array");
1543 r = buxton_array_add(out_list, &data2);
1544 fail_if(!r, "Failed to add element to array");
1545 r = buxton_array_add(out_list, &data3);
1546 fail_if(!r, "Failed to add element to array");
1547 size = buxton_serialize_message(&cl.data, BUXTON_CONTROL_NOTIFY, 0,
1549 fail_if(size == 0, "Failed to serialize message");
1550 r = buxtond_handle_message(&daemon, &cl, size);
1552 fail_if(!r, "Failed to register for notification");
1554 s = read(client, buf, 4096);
1555 fail_if(s < 0, "Read from client failed");
1556 csize = buxton_deserialize_message(buf, &msg, (size_t)s, &msgid, &list);
1557 fail_if(csize != 1, "Failed to get correct response to notify");
1558 fail_if(msg != BUXTON_CONTROL_STATUS,
1559 "Failed to get correct control type");
1560 fail_if(msgid != 0, "Failed to get correct notify message id");
1561 fail_if(list[0].type != INT32, "Failed to get correct response type");
1562 fail_if(list[0].store.d_int32 != 0,
1563 "Failed to register notification");
1568 size = buxton_serialize_message(&cl.data, BUXTON_CONTROL_UNNOTIFY, 0,
1570 fail_if(size == 0, "Failed to serialize message");
1571 r = buxtond_handle_message(&daemon, &cl, size);
1573 fail_if(!r, "Failed to unregister from notification");
1575 s = read(client, buf, 4096);
1576 fail_if(s < 0, "Read from client failed 2");
1577 csize = buxton_deserialize_message(buf, &msg, (size_t)s, &msgid, &list);
1578 fail_if(csize != 2, "Failed to get correct response to unnotify");
1579 fail_if(msg != BUXTON_CONTROL_STATUS,
1580 "Failed to get correct control type 2");
1581 fail_if(list[0].type != INT32,
1582 "Failed to get correct indicator type 2");
1583 fail_if(list[0].store.d_int32 != 0,
1584 "Failed to unregister for notification");
1585 fail_if(list[1].type != UINT32,
1586 "Failed to get correct unnotify message id type");
1587 fail_if(list[1].store.d_uint32 != 0,
1588 "Failed to get correct unnotify message id");
1589 fail_if(msgid != 0, "Failed to get correct message id 2");
1593 hashmap_free(daemon.notify_mapping);
1594 buxton_direct_close(&daemon.buxton);
1595 buxton_array_free(&out_list, NULL);
1599 START_TEST(buxtond_handle_message_unset_check)
1602 BuxtonDaemon daemon;
1603 BuxtonString slabel;
1605 BuxtonData data1, data2, data3, data4;
1606 client_list_item cl;
1609 BuxtonArray *out_list;
1610 BuxtonControlMessage msg;
1616 setup_socket_pair(&client, &server);
1617 out_list = buxton_array_new();
1618 fail_if(!out_list, "Failed to allocate list");
1621 slabel = buxton_string_pack("_");
1623 cl.smack_label = &slabel;
1625 cl.smack_label = NULL;
1627 daemon.buxton.client.uid = 1001;
1628 fail_if(!buxton_cache_smack_rules(), "Failed to cache Smack rules");
1629 fail_if(!buxton_direct_open(&daemon.buxton),
1630 "Failed to open buxton direct connection");
1631 daemon.notify_mapping = hashmap_new(string_hash_func, string_compare_func);
1632 fail_if(!daemon.notify_mapping, "Failed to allocate hashmap");
1634 data1.type = STRING;
1635 data1.store.d_string = buxton_string_pack("base");
1636 data2.type = STRING;
1637 data2.store.d_string = buxton_string_pack("daemon-check");
1638 data3.type = STRING;
1639 data3.store.d_string = buxton_string_pack("name");
1640 data4.type = UINT32;
1641 data4.store.d_uint32 = STRING;
1642 r = buxton_array_add(out_list, &data1);
1643 fail_if(!r, "Failed to add element to array");
1644 r = buxton_array_add(out_list, &data2);
1645 fail_if(!r, "Failed to add element to array");
1646 r = buxton_array_add(out_list, &data3);
1647 fail_if(!r, "Failed to add element to array");
1648 r = buxton_array_add(out_list, &data4);
1649 fail_if(!r, "Failed to add element to array");
1650 size = buxton_serialize_message(&cl.data, BUXTON_CONTROL_UNSET, 0,
1652 fail_if(size == 0, "Failed to serialize message");
1653 r = buxtond_handle_message(&daemon, &cl, size);
1655 fail_if(!r, "Failed to unset message");
1657 s = read(client, buf, 4096);
1658 fail_if(s < 0, "Read from client failed");
1659 csize = buxton_deserialize_message(buf, &msg, (size_t)s, &msgid, &list);
1660 fail_if(csize != 1, "Failed to get correct response to unset");
1661 fail_if(msg != BUXTON_CONTROL_STATUS,
1662 "Failed to get correct control type");
1663 fail_if(list[0].type != INT32,
1664 "Failed to get correct indicator type");
1665 fail_if(list[0].store.d_int32 != 0,
1667 fail_if(msgid != 0, "Failed to get correct message id");
1671 hashmap_free(daemon.notify_mapping);
1672 buxton_direct_close(&daemon.buxton);
1673 buxton_array_free(&out_list, NULL);
1677 START_TEST(buxtond_notify_clients_check)
1680 BuxtonDaemon daemon;
1682 BuxtonString slabel;
1683 BuxtonData value1, value2;
1684 client_list_item cl;
1688 BuxtonControlMessage msg;
1694 setup_socket_pair(&client, &server);
1697 slabel = buxton_string_pack("_");
1699 cl.smack_label = &slabel;
1701 cl.smack_label = NULL;
1703 daemon.notify_mapping = hashmap_new(string_hash_func,
1704 string_compare_func);
1705 fail_if(!daemon.notify_mapping, "Failed to allocate hashmap");
1706 fail_if(!buxton_cache_smack_rules(),
1707 "Failed to cache Smack rules");
1708 fail_if(!buxton_direct_open(&daemon.buxton),
1709 "Failed to open buxton direct connection");
1711 value1.type = STRING;
1712 value1.store.d_string = buxton_string_pack("dummy value");
1713 key.group = buxton_string_pack("dummy");
1714 key.name = buxton_string_pack("name");
1715 buxtond_notify_clients(&daemon, &cl, &key, &value1);
1717 value1.store.d_string = buxton_string_pack("real value");
1718 key.group = buxton_string_pack("daemon-check");
1719 key.name = buxton_string_pack("name");
1720 key.layer = buxton_string_pack("base");
1722 r = buxton_direct_set_value(&daemon.buxton, &key,
1724 fail_if(!r, "Failed to set value for notify");
1725 register_notification(&daemon, &cl, &key, 0, &status);
1726 fail_if(status != 0,
1727 "Failed to register notification for notify");
1728 buxtond_notify_clients(&daemon, &cl, &key, &value1);
1730 value2.type = STRING;
1731 value2.store.d_string = buxton_string_pack("new value");
1732 buxtond_notify_clients(&daemon, &cl, &key, &value2);
1734 s = read(client, buf, 4096);
1735 fail_if(s < 0, "Read from client failed");
1736 csize = buxton_deserialize_message(buf, &msg, (size_t)s, &msgid, &list);
1738 "Failed to get correct response to notify string");
1739 fail_if(msg != BUXTON_CONTROL_CHANGED,
1740 "Failed to get correct control type");
1741 fail_if(msgid != 0, "Failed to get correct message id");
1742 fail_if(list[0].type != STRING,
1743 "Failed to get correct notification value type string");
1744 fail_if(!streq(list[0].store.d_string.value, "new value"),
1745 "Failed to get correct notification value data string");
1747 free(list[0].store.d_string.value);
1750 key.group = buxton_string_pack("group");
1751 key.name.value = NULL;
1752 key.name.length = 0;
1753 r = buxton_direct_create_group(&daemon.buxton, &key, NULL);
1754 fail_if(!r, "Unable to create group");
1755 r = buxton_direct_set_label(&daemon.buxton, &key, &slabel);
1756 fail_if(!r, "Unable set group label");
1758 value1.type = INT32;
1759 value1.store.d_int32 = 1;
1760 value2.type = INT32;
1761 value2.store.d_int32 = 2;
1762 key.group = buxton_string_pack("group");
1763 key.name = buxton_string_pack("name32");
1765 r = buxton_direct_set_value(&daemon.buxton, &key,
1767 fail_if(!r, "Failed to set value for notify");
1768 register_notification(&daemon, &cl, &key, 0, &status);
1769 fail_if(status != 0,
1770 "Failed to register notification for notify");
1771 buxtond_notify_clients(&daemon, &cl, &key, &value2);
1773 s = read(client, buf, 4096);
1774 fail_if(s < 0, "Read from client failed");
1775 csize = buxton_deserialize_message(buf, &msg, (size_t)s, &msgid, &list);
1777 "Failed to get correct response to notify int32");
1778 fail_if(msg != BUXTON_CONTROL_CHANGED,
1779 "Failed to get correct control type");
1780 fail_if(msgid != 0, "Failed to get correct message id");
1781 fail_if(list[0].type != INT32,
1782 "Failed to get correct notification value type int32");
1783 fail_if(list[0].store.d_int32 != 2,
1784 "Failed to get correct notification value data int32");
1788 value1.type = UINT32;
1789 value1.store.d_uint32 = 1;
1790 value2.type = UINT32;
1791 value2.store.d_uint32 = 2;
1792 key.group = buxton_string_pack("group");
1793 key.name = buxton_string_pack("nameu32");
1795 r = buxton_direct_set_value(&daemon.buxton, &key,
1797 fail_if(!r, "Failed to set value for notify");
1798 register_notification(&daemon, &cl, &key, 0, &status);
1799 fail_if(status != 0,
1800 "Failed to register notification for notify");
1801 buxtond_notify_clients(&daemon, &cl, &key, &value2);
1803 s = read(client, buf, 4096);
1804 fail_if(s < 0, "Read from client failed");
1805 csize = buxton_deserialize_message(buf, &msg, (size_t)s, &msgid, &list);
1807 "Failed to get correct response to notify uint32");
1808 fail_if(msg != BUXTON_CONTROL_CHANGED,
1809 "Failed to get correct control type");
1810 fail_if(msgid != 0, "Failed to get correct message id");
1811 fail_if(list[0].type != UINT32,
1812 "Failed to get correct notification value type uint32");
1813 fail_if(list[0].store.d_uint32 != 2,
1814 "Failed to get correct notification value data uint32");
1818 value1.type = INT64;
1819 value1.store.d_int64 = 2;
1820 value2.type = INT64;
1821 value2.store.d_int64 = 3;
1822 key.group = buxton_string_pack("group");
1823 key.name = buxton_string_pack("name64");
1825 r = buxton_direct_set_value(&daemon.buxton, &key,
1827 fail_if(!r, "Failed to set value for notify");
1828 register_notification(&daemon, &cl, &key, 0, &status);
1829 fail_if(status != 0,
1830 "Failed to register notification for notify");
1831 buxtond_notify_clients(&daemon, &cl, &key, &value2);
1833 s = read(client, buf, 4096);
1834 fail_if(s < 0, "Read from client failed");
1835 csize = buxton_deserialize_message(buf, &msg, (size_t)s, &msgid, &list);
1837 "Failed to get correct response to notify int64");
1838 fail_if(msg != BUXTON_CONTROL_CHANGED,
1839 "Failed to get correct control type");
1840 fail_if(msgid != 0, "Failed to get correct message id");
1841 fail_if(list[0].type != INT64,
1842 "Failed to get correct notification value type int 64");
1843 fail_if(list[0].store.d_int64 != 3,
1844 "Failed to get correct notification value data int64");
1848 value1.type = UINT64;
1849 value1.store.d_uint64 = 2;
1850 value2.type = UINT64;
1851 value2.store.d_uint64 = 3;
1852 key.group = buxton_string_pack("group");
1853 key.name = buxton_string_pack("nameu64");
1855 r = buxton_direct_set_value(&daemon.buxton, &key,
1857 fail_if(!r, "Failed to set value for notify");
1858 register_notification(&daemon, &cl, &key, 0, &status);
1859 fail_if(status != 0,
1860 "Failed to register notification for notify");
1861 buxtond_notify_clients(&daemon, &cl, &key, &value2);
1863 s = read(client, buf, 4096);
1864 fail_if(s < 0, "Read from client failed");
1865 csize = buxton_deserialize_message(buf, &msg, (size_t)s, &msgid, &list);
1867 "Failed to get correct response to notify uint64");
1868 fail_if(msg != BUXTON_CONTROL_CHANGED,
1869 "Failed to get correct control type");
1870 fail_if(msgid != 0, "Failed to get correct message id");
1871 fail_if(list[0].type != UINT64,
1872 "Failed to get correct notification value type uint64");
1873 fail_if(list[0].store.d_uint64 != 3,
1874 "Failed to get correct notification value data uint64");
1878 value1.type = FLOAT;
1879 value1.store.d_float = 3.1F;
1880 value2.type = FLOAT;
1881 value2.store.d_float = 3.14F;
1882 key.group = buxton_string_pack("group");
1883 key.name = buxton_string_pack("namef");
1885 r = buxton_direct_set_value(&daemon.buxton, &key,
1887 fail_if(!r, "Failed to set value for notify");
1888 register_notification(&daemon, &cl, &key, 0, &status);
1889 fail_if(status != 0,
1890 "Failed to register notification for notify");
1891 buxtond_notify_clients(&daemon, &cl, &key, &value2);
1893 s = read(client, buf, 4096);
1894 fail_if(s < 0, "Read from client failed");
1895 csize = buxton_deserialize_message(buf, &msg, (size_t)s, &msgid, &list);
1897 "Failed to get correct response to notify float");
1898 fail_if(msg != BUXTON_CONTROL_CHANGED,
1899 "Failed to get correct control type");
1900 fail_if(msgid != 0, "Failed to get correct message id");
1901 fail_if(list[0].type != FLOAT,
1902 "Failed to get correct notification value type float");
1903 fail_if(list[0].store.d_float != 3.14F,
1904 "Failed to get correct notification value data float");
1908 value1.type = DOUBLE;
1909 value1.store.d_double = 3.141F;
1910 value2.type = DOUBLE;
1911 value2.store.d_double = 3.1415F;
1912 key.group = buxton_string_pack("group");
1913 key.name = buxton_string_pack("named");
1915 r = buxton_direct_set_value(&daemon.buxton, &key,
1917 fail_if(!r, "Failed to set value for notify");
1918 register_notification(&daemon, &cl, &key, 0, &status);
1919 fail_if(status != 0,
1920 "Failed to register notification for notify");
1921 buxtond_notify_clients(&daemon, &cl, &key, &value2);
1923 s = read(client, buf, 4096);
1924 fail_if(s < 0, "Read from client failed");
1925 csize = buxton_deserialize_message(buf, &msg, (size_t)s, &msgid, &list);
1927 "Failed to get correct response to notify double");
1928 fail_if(msg != BUXTON_CONTROL_CHANGED,
1929 "Failed to get correct control type");
1930 fail_if(msgid != 0, "Failed to get correct message id");
1931 fail_if(list[0].type != DOUBLE,
1932 "Failed to get correct notification value type double");
1933 fail_if(list[0].store.d_double != 3.1415F,
1934 "Failed to get correct notification value data double");
1938 value1.type = BOOLEAN;
1939 value1.store.d_boolean = false;
1940 value2.type = BOOLEAN;
1941 value2.store.d_int32 = true;
1942 key.group = buxton_string_pack("group");
1943 key.name = buxton_string_pack("nameb");
1945 r = buxton_direct_set_value(&daemon.buxton, &key,
1947 fail_if(!r, "Failed to set value for notify");
1948 register_notification(&daemon, &cl, &key, 0, &status);
1949 fail_if(status != 0,
1950 "Failed to register notification for notify");
1951 buxtond_notify_clients(&daemon, &cl, &key, &value2);
1953 s = read(client, buf, 4096);
1954 fail_if(s < 0, "Read from client failed");
1955 csize = buxton_deserialize_message(buf, &msg, (size_t)s, &msgid, &list);
1957 "Failed to get correct response to notify bool");
1958 fail_if(msg != BUXTON_CONTROL_CHANGED,
1959 "Failed to get correct control type");
1960 fail_if(msgid != 0, "Failed to get correct message id");
1961 fail_if(list[0].type != BOOLEAN,
1962 "Failed to get correct notification value type bool");
1963 fail_if(list[0].store.d_boolean != true,
1964 "Failed to get correct notification value data bool");
1968 buxton_direct_close(&daemon.buxton);
1972 START_TEST(identify_client_check)
1975 client_list_item client;
1979 setup_socket_pair(&client.fd, &sender);
1980 r = identify_client(&client);
1981 fail_if(r, "Identified client without message");
1983 write(sender, &msg, sizeof(int32_t));
1984 r = identify_client(&client);
1985 fail_if(!r, "Identify client failed");
1992 START_TEST(add_pollfd_check)
1994 BuxtonDaemon daemon;
2000 daemon.nfds_alloc = 0;
2001 daemon.accepting_alloc = 0;
2003 daemon.pollfds = NULL;
2004 daemon.accepting = NULL;
2007 add_pollfd(&daemon, fd, events, a);
2008 fail_if(daemon.nfds != 1, "Failed to increase nfds");
2009 fail_if(daemon.pollfds[0].fd != fd, "Failed to set pollfd");
2010 fail_if(daemon.pollfds[0].events != events, "Failed to set events");
2011 fail_if(daemon.pollfds[0].revents != 0, "Failed to set revents");
2012 fail_if(daemon.accepting[0] != a, "Failed to set accepting status");
2013 free(daemon.pollfds);
2014 free(daemon.accepting);
2018 START_TEST(del_pollfd_check)
2020 BuxtonDaemon daemon;
2026 daemon.nfds_alloc = 0;
2027 daemon.accepting_alloc = 0;
2029 daemon.pollfds = NULL;
2030 daemon.accepting = NULL;
2033 add_pollfd(&daemon, fd, events, a);
2034 fail_if(daemon.nfds != 1, "Failed to add pollfd");
2035 del_pollfd(&daemon, 0);
2036 fail_if(daemon.nfds != 0, "Failed to decrease nfds 1");
2041 add_pollfd(&daemon, fd, events, a);
2042 fail_if(daemon.nfds != 1, "Failed to increase nfds after del");
2043 fail_if(daemon.pollfds[0].fd != fd, "Failed to set pollfd after del");
2044 fail_if(daemon.pollfds[0].events != events,
2045 "Failed to set events after del");
2046 fail_if(daemon.pollfds[0].revents != 0,
2047 "Failed to set revents after del");
2048 fail_if(daemon.accepting[0] != a,
2049 "Failed to set accepting status after del");
2053 add_pollfd(&daemon, fd, events, a);
2054 del_pollfd(&daemon, 0);
2055 fail_if(daemon.nfds != 1, "Failed to delete fd 2");
2056 fail_if(daemon.pollfds[0].fd != fd, "Failed to set pollfd after del2");
2057 fail_if(daemon.pollfds[0].events != events,
2058 "Failed to set events after del2");
2059 fail_if(daemon.pollfds[0].revents != 0,
2060 "Failed to set revents after del2");
2061 fail_if(daemon.accepting[0] != a,
2062 "Failed to set accepting status after del2");
2066 START_TEST(handle_client_check)
2071 START_TEST(buxtond_eat_garbage_check)
2077 unlink(buxton_socket());
2079 sigemptyset(&sigset);
2080 sigaddset(&sigset, SIGCHLD);
2081 sigprocmask(SIG_BLOCK, &sigset, NULL);
2084 fail_if(pid < 0, "couldn't fork");
2085 if (pid) { /* parent*/
2089 bool keep_going = true;
2094 bzero(&fuzz, sizeof(FuzzContext));
2098 check_did_not_crash(daemon_pid, &fuzz);
2101 fail_if(time(&start) == -1, "call to time() failed");
2107 fail_if(time(&now) == -1, "call to time() failed");
2108 if (now - start >= fuzz_time) {
2112 fuzz.size = (unsigned int)rand() % 4096;
2113 for (int i=0; i < fuzz.size; i++) {
2114 fuzz.buf[i] = (uint8_t)(rand() % 255);
2116 if ((fuzz.size >= 6) && (rand() % 4096)) {
2117 uint16_t control = (uint16_t)((rand() % (BUXTON_CONTROL_MAX-1)) + 1);
2123 /* valid message type */
2124 memcpy((void*)(fuzz.buf + 2), (void*)(&control), sizeof(uint16_t));
2127 memcpy((void *)(fuzz.buf + 4), (void *)(&fuzz.size), sizeof(uint32_t));
2130 fail_if(client == -1, "couldn't fork");
2132 fd = buxton_open(&c);
2134 "Open failed with daemon%s", dump_fuzz(&fuzz));
2137 bytes = write(fd, (void*)(fuzz.buf), fuzz.size);
2138 fail_if(bytes == -1, "write failed: %m%s", dump_fuzz(&fuzz));
2139 fail_unless(bytes == fuzz.size, "write was %d instead of %d", bytes, fuzz.size);
2144 check_did_not_crash(daemon_pid, &fuzz);
2148 pid_t wait = waitpid(client, &status, 0);
2149 fail_if(wait == -1, "waitpid failed");
2150 fail_unless(WIFEXITED(status), "client died");
2153 } while (keep_going);
2154 } else { /* child */
2166 s = suite_create("daemon");
2167 tc = tcase_create("daemon test functions");
2168 tcase_add_checked_fixture(tc, setup, teardown);
2169 tcase_add_test(tc, buxton_open_check);
2170 tcase_add_test(tc, buxton_create_group_check);
2171 tcase_add_test(tc, buxton_remove_group_check);
2172 tcase_add_test(tc, buxton_set_value_check);
2173 tcase_add_test(tc, buxton_set_label_check);
2174 tcase_add_test(tc, buxton_get_value_for_layer_check);
2175 tcase_add_test(tc, buxton_get_value_check);
2176 suite_add_tcase(s, tc);
2178 tc = tcase_create("buxton_daemon_functions");
2179 tcase_add_test(tc, parse_list_check);
2180 tcase_add_test(tc, create_group_check);
2181 tcase_add_test(tc, remove_group_check);
2182 tcase_add_test(tc, set_label_check);
2183 tcase_add_test(tc, set_value_check);
2184 tcase_add_test(tc, get_value_check);
2185 tcase_add_test(tc, register_notification_check);
2186 tcase_add_test(tc, buxtond_handle_message_error_check);
2187 tcase_add_test(tc, buxtond_handle_message_create_group_check);
2188 tcase_add_test(tc, buxtond_handle_message_remove_group_check);
2189 tcase_add_test(tc, buxtond_handle_message_set_label_check);
2190 tcase_add_test(tc, buxtond_handle_message_set_value_check);
2191 tcase_add_test(tc, buxtond_handle_message_get_check);
2192 tcase_add_test(tc, buxtond_handle_message_notify_check);
2193 tcase_add_test(tc, buxtond_handle_message_unset_check);
2194 tcase_add_test(tc, buxtond_notify_clients_check);
2195 tcase_add_test(tc, identify_client_check);
2196 tcase_add_test(tc, add_pollfd_check);
2197 tcase_add_test(tc, del_pollfd_check);
2198 tcase_add_test(tc, handle_client_check);
2199 suite_add_tcase(s, tc);
2201 tc = tcase_create("buxton daemon evil tests");
2202 tcase_add_checked_fixture(tc, NULL, teardown);
2203 tcase_add_test(tc, buxtond_eat_garbage_check);
2204 tcase_set_timeout(tc, fuzz_time+2);
2205 suite_add_tcase(s, tc);
2217 putenv("BUXTON_CONF_FILE=" ABS_TOP_BUILDDIR "/test/test.conf");
2218 putenv("BUXTON_ROOT_CHECK=0");
2219 fuzzenv = getenv("BUXTON_FUZZ_TIME");
2221 fuzz_time = atoi(fuzzenv);
2225 sr = srunner_create(s);
2226 srunner_run_all(sr, CK_VERBOSE);
2227 number_failed = srunner_ntests_failed(sr);
2230 return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
2234 * Editor modelines - http://www.wireshark.org/tools/modelines.html
2239 * indent-tabs-mode: t
2242 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
2243 * :indentSize=8:tabSize=8:noTabs=false: