Lines Matching +full:1 +full:- +full:2

7  * 1. Redistributions of source code must retain the above copyright
9 * 2. Redistributions in binary form must reproduce the above copyright
26 #include "atf-c/macros.h"
40 #include <atf-c.h>
42 #include "atf-c/detail/fs.h"
43 #include "atf-c/detail/process.h"
44 #include "atf-c/detail/test_helpers.h"
45 #include "atf-c/detail/text.h"
47 /* ---------------------------------------------------------------------
49 * --------------------------------------------------------------------- */
59 O_CREAT | O_WRONLY | O_TRUNC, 0644) != -1); in create_ctl_file()
90 /* ---------------------------------------------------------------------
92 * --------------------------------------------------------------------- */
208 /* ---------------------------------------------------------------------
210 * --------------------------------------------------------------------- */
216 return -1; in errno_fail_stub()
225 H_CHECK_ERRNO(no_error, -1, errno_ok_stub() == -1);
226 H_CHECK_ERRNO(errno_ok, 2, errno_fail_stub(2) == -1);
227 H_CHECK_ERRNO(errno_fail, 3, errno_fail_stub(4) == -1);
229 H_REQUIRE_ERRNO(no_error, -1, errno_ok_stub() == -1);
230 H_REQUIRE_ERRNO(errno_ok, 2, errno_fail_stub(2) == -1);
231 H_REQUIRE_ERRNO(errno_fail, 3, errno_fail_stub(4) == -1);
248 false, "Expected true value in errno_ok_stub\\(\\) == -1" }, in ATF_TC_BODY()
254 false, "Expected errno 3, got 4, in errno_fail_stub\\(4\\) == -1" }, in ATF_TC_BODY()
258 for (t = &tests[0]; t->head != NULL; t++) { in ATF_TC_BODY()
259 init_and_run_h_tc("h_check_errno", t->head, t->body); in ATF_TC_BODY()
264 if (t->ok) { in ATF_TC_BODY()
269 "macros_test.c:[0-9]+: %s$", "error", t->exp_regex)); in ATF_TC_BODY()
272 ATF_REQUIRE(unlink("before") != -1); in ATF_TC_BODY()
273 ATF_REQUIRE(unlink("after") != -1); in ATF_TC_BODY()
292 false, "Expected true value in errno_ok_stub\\(\\) == -1" }, in ATF_TC_BODY()
298 false, "Expected errno 3, got 4, in errno_fail_stub\\(4\\) == -1" }, in ATF_TC_BODY()
302 for (t = &tests[0]; t->head != NULL; t++) { in ATF_TC_BODY()
303 init_and_run_h_tc("h_require_errno", t->head, t->body); in ATF_TC_BODY()
306 if (t->ok) { in ATF_TC_BODY()
311 "^failed: .*macros_test.c:[0-9]+: %s$", "result", in ATF_TC_BODY()
312 t->exp_regex)); in ATF_TC_BODY()
316 ATF_REQUIRE(unlink("before") != -1); in ATF_TC_BODY()
317 if (t->ok) in ATF_TC_BODY()
318 ATF_REQUIRE(unlink("after") != -1); in ATF_TC_BODY()
322 /* ---------------------------------------------------------------------
324 * --------------------------------------------------------------------- */
327 H_CHECK(1, 1);
329 H_CHECK_MSG(1, 1, "expected a true value");
348 { H_CHECK_HEAD_NAME(1), H_CHECK_BODY_NAME(1), 1, in ATF_TC_BODY()
349 "1 not met", true }, in ATF_TC_BODY()
352 { H_CHECK_MSG_HEAD_NAME(1), H_CHECK_MSG_BODY_NAME(1), 1, in ATF_TC_BODY()
357 for (t = &tests[0]; t->head != NULL; t++) { in ATF_TC_BODY()
358 printf("Checking with a %d value\n", t->value); in ATF_TC_BODY()
360 init_and_run_h_tc("h_check", t->head, t->body); in ATF_TC_BODY()
365 if (t->ok) { in ATF_TC_BODY()
370 "macros_test.c:[0-9]+: %s$", "error", t->msg)); in ATF_TC_BODY()
373 ATF_REQUIRE(unlink("before") != -1); in ATF_TC_BODY()
374 ATF_REQUIRE(unlink("after") != -1); in ATF_TC_BODY()
378 /* ---------------------------------------------------------------------
380 * --------------------------------------------------------------------- */
397 for (t = &tests[0]; t->head != NULL; t++) { in do_check_eq_tests()
398 printf("Checking with %s, %s and expecting %s\n", t->v1, t->v2, in do_check_eq_tests()
399 t->ok ? "true" : "false"); in do_check_eq_tests()
401 init_and_run_h_tc("h_check", t->head, t->body); in do_check_eq_tests()
406 if (t->ok) { in do_check_eq_tests()
411 "macros_test.c:[0-9]+: %s$", "error", t->msg)); in do_check_eq_tests()
414 ATF_CHECK(unlink("before") != -1); in do_check_eq_tests()
415 ATF_CHECK(unlink("after") != -1); in do_check_eq_tests()
419 H_CHECK_EQ(1_1, 1, 1);
420 H_CHECK_EQ(1_2, 1, 2);
421 H_CHECK_EQ(2_1, 2, 1);
422 H_CHECK_EQ(2_2, 2, 2);
423 H_CHECK_EQ_MSG(1_1, 1, 1, "1 does not match 1");
424 H_CHECK_EQ_MSG(1_2, 1, 2, "1 does not match 2");
425 H_CHECK_EQ_MSG(2_1, 2, 1, "2 does not match 1");
426 H_CHECK_EQ_MSG(2_2, 2, 2, "2 does not match 2");
437 { H_CHECK_EQ_HEAD_NAME(1_1), H_CHECK_EQ_BODY_NAME(1_1), in ATF_TC_BODY()
438 "1", "1", "1 != 1", true }, in ATF_TC_BODY()
439 { H_CHECK_EQ_HEAD_NAME(1_2), H_CHECK_EQ_BODY_NAME(1_2), in ATF_TC_BODY()
440 "1", "2", "1 != 2", false }, in ATF_TC_BODY()
441 { H_CHECK_EQ_HEAD_NAME(2_1), H_CHECK_EQ_BODY_NAME(2_1), in ATF_TC_BODY()
442 "2", "1", "2 != 1", false }, in ATF_TC_BODY()
443 { H_CHECK_EQ_HEAD_NAME(2_2), H_CHECK_EQ_BODY_NAME(2_2), in ATF_TC_BODY()
444 "2", "2", "2 != 2", true }, in ATF_TC_BODY()
445 { H_CHECK_EQ_MSG_HEAD_NAME(1_1), H_CHECK_EQ_MSG_BODY_NAME(1_1), in ATF_TC_BODY()
446 "1", "1", "1 != 1: 1 does not match 1", true }, in ATF_TC_BODY()
447 { H_CHECK_EQ_MSG_HEAD_NAME(1_2), H_CHECK_EQ_MSG_BODY_NAME(1_2), in ATF_TC_BODY()
448 "1", "2", "1 != 2: 1 does not match 2", false }, in ATF_TC_BODY()
449 { H_CHECK_EQ_MSG_HEAD_NAME(2_1), H_CHECK_EQ_MSG_BODY_NAME(2_1), in ATF_TC_BODY()
450 "2", "1", "2 != 1: 2 does not match 1", false }, in ATF_TC_BODY()
451 { H_CHECK_EQ_MSG_HEAD_NAME(2_2), H_CHECK_EQ_MSG_BODY_NAME(2_2), in ATF_TC_BODY()
452 "2", "2", "2 != 2: 2 does not match 2", true }, in ATF_TC_BODY()
458 H_CHECK_STREQ(1_1, "1", "1");
459 H_CHECK_STREQ(1_2, "1", "2");
460 H_CHECK_STREQ(2_1, "2", "1");
461 H_CHECK_STREQ(2_2, "2", "2");
462 H_CHECK_STREQ_MSG(1_1, "1", "1", "1 does not match 1");
463 H_CHECK_STREQ_MSG(1_2, "1", "2", "1 does not match 2");
464 H_CHECK_STREQ_MSG(2_1, "2", "1", "2 does not match 1");
465 H_CHECK_STREQ_MSG(2_2, "2", "2", "2 does not match 2");
481 { H_CHECK_STREQ_HEAD_NAME(1_1), H_CHECK_STREQ_BODY_NAME(1_1), in ATF_TC_BODY()
482 "1", "1", "\"1\" != \"1\" \\(1 != 1\\)", true }, in ATF_TC_BODY()
483 { H_CHECK_STREQ_HEAD_NAME(1_2), H_CHECK_STREQ_BODY_NAME(1_2), in ATF_TC_BODY()
484 "1", "2", "\"1\" != \"2\" \\(1 != 2\\)", false }, in ATF_TC_BODY()
485 { H_CHECK_STREQ_HEAD_NAME(2_1), H_CHECK_STREQ_BODY_NAME(2_1), in ATF_TC_BODY()
486 "2", "1", "\"2\" != \"1\" \\(2 != 1\\)", false }, in ATF_TC_BODY()
487 { H_CHECK_STREQ_HEAD_NAME(2_2), H_CHECK_STREQ_BODY_NAME(2_2), in ATF_TC_BODY()
488 "2", "2", "\"2\" != \"2\" \\(2 != 2\\)", true }, in ATF_TC_BODY()
489 { H_CHECK_STREQ_MSG_HEAD_NAME(1_1), in ATF_TC_BODY()
490 H_CHECK_STREQ_MSG_BODY_NAME(1_1), in ATF_TC_BODY()
491 "1", "1", "\"1\" != \"1\" \\(1 != 1\\): 1 does not match 1", true }, in ATF_TC_BODY()
492 { H_CHECK_STREQ_MSG_HEAD_NAME(1_2), in ATF_TC_BODY()
493 H_CHECK_STREQ_MSG_BODY_NAME(1_2), in ATF_TC_BODY()
494 "1", "2", "\"1\" != \"2\" \\(1 != 2\\): 1 does not match 2", false }, in ATF_TC_BODY()
495 { H_CHECK_STREQ_MSG_HEAD_NAME(2_1), in ATF_TC_BODY()
496 H_CHECK_STREQ_MSG_BODY_NAME(2_1), in ATF_TC_BODY()
497 "2", "1", "\"2\" != \"1\" \\(2 != 1\\): 2 does not match 1", false }, in ATF_TC_BODY()
498 { H_CHECK_STREQ_MSG_HEAD_NAME(2_2), in ATF_TC_BODY()
499 H_CHECK_STREQ_MSG_BODY_NAME(2_2), in ATF_TC_BODY()
500 "2", "2", "\"2\" != \"2\" \\(2 != 2\\): 2 does not match 2", true }, in ATF_TC_BODY()
510 /* ---------------------------------------------------------------------
512 * --------------------------------------------------------------------- */
514 H_CHECK_MATCH(yes, "hello [a-z]+", "abc hello world");
515 H_CHECK_MATCH(no, "hello [a-z]+", "abc hello WORLD");
516 H_CHECK_MATCH_MSG(yes, "hello [a-z]+", "abc hello world", "lowercase");
517 H_CHECK_MATCH_MSG(no, "hello [a-z]+", "abc hello WORLD", "uppercase");
529 "hello [a-z]+", "abc hello world", "", true }, in ATF_TC_BODY()
531 "hello [a-z]+", "abc hello WORLD", in ATF_TC_BODY()
532 "'hello \\[a-z\\]\\+' not matched in 'abc hello WORLD'", false }, in ATF_TC_BODY()
534 "hello [a-z]+", "abc hello world", "", true }, in ATF_TC_BODY()
536 "hello [a-z]+", "abc hello WORLD", in ATF_TC_BODY()
537 "'hello \\[a-z\\]\\+' not matched in 'abc hello WORLD': uppercase", in ATF_TC_BODY()
544 /* ---------------------------------------------------------------------
546 * --------------------------------------------------------------------- */
549 H_REQUIRE(1, 1);
551 H_REQUIRE_MSG(1, 1, "expected a true value");
570 { H_REQUIRE_HEAD_NAME(1), H_REQUIRE_BODY_NAME(1), 1, in ATF_TC_BODY()
571 "1 not met", true }, in ATF_TC_BODY()
574 { H_REQUIRE_MSG_HEAD_NAME(1), H_REQUIRE_MSG_BODY_NAME(1), 1, in ATF_TC_BODY()
579 for (t = &tests[0]; t->head != NULL; t++) { in ATF_TC_BODY()
580 printf("Checking with a %d value\n", t->value); in ATF_TC_BODY()
582 init_and_run_h_tc("h_require", t->head, t->body); in ATF_TC_BODY()
585 if (t->ok) { in ATF_TC_BODY()
590 "^failed: .*macros_test.c:[0-9]+: %s$", "result", t->msg)); in ATF_TC_BODY()
594 ATF_REQUIRE(unlink("before") != -1); in ATF_TC_BODY()
595 if (t->ok) in ATF_TC_BODY()
596 ATF_REQUIRE(unlink("after") != -1); in ATF_TC_BODY()
600 /* ---------------------------------------------------------------------
602 * --------------------------------------------------------------------- */
619 for (t = &tests[0]; t->head != NULL; t++) { in do_require_eq_tests()
620 printf("Checking with %s, %s and expecting %s\n", t->v1, t->v2, in do_require_eq_tests()
621 t->ok ? "true" : "false"); in do_require_eq_tests()
623 init_and_run_h_tc("h_require", t->head, t->body); in do_require_eq_tests()
626 if (t->ok) { in do_require_eq_tests()
631 ":[0-9]+: %s$", "result", t->msg)); in do_require_eq_tests()
635 ATF_REQUIRE(unlink("before") != -1); in do_require_eq_tests()
636 if (t->ok) in do_require_eq_tests()
637 ATF_REQUIRE(unlink("after") != -1); in do_require_eq_tests()
641 H_REQUIRE_EQ(1_1, 1, 1);
642 H_REQUIRE_EQ(1_2, 1, 2);
643 H_REQUIRE_EQ(2_1, 2, 1);
644 H_REQUIRE_EQ(2_2, 2, 2);
645 H_REQUIRE_EQ_MSG(1_1, 1, 1, "1 does not match 1");
646 H_REQUIRE_EQ_MSG(1_2, 1, 2, "1 does not match 2");
647 H_REQUIRE_EQ_MSG(2_1, 2, 1, "2 does not match 1");
648 H_REQUIRE_EQ_MSG(2_2, 2, 2, "2 does not match 2");
659 { H_REQUIRE_EQ_HEAD_NAME(1_1), H_REQUIRE_EQ_BODY_NAME(1_1), in ATF_TC_BODY()
660 "1", "1", "1 != 1", true }, in ATF_TC_BODY()
661 { H_REQUIRE_EQ_HEAD_NAME(1_2), H_REQUIRE_EQ_BODY_NAME(1_2), in ATF_TC_BODY()
662 "1", "2", "1 != 2", false }, in ATF_TC_BODY()
663 { H_REQUIRE_EQ_HEAD_NAME(2_1), H_REQUIRE_EQ_BODY_NAME(2_1), in ATF_TC_BODY()
664 "2", "1", "2 != 1", false }, in ATF_TC_BODY()
665 { H_REQUIRE_EQ_HEAD_NAME(2_2), H_REQUIRE_EQ_BODY_NAME(2_2), in ATF_TC_BODY()
666 "2", "2", "2 != 2", true }, in ATF_TC_BODY()
667 { H_REQUIRE_EQ_MSG_HEAD_NAME(1_1), H_REQUIRE_EQ_MSG_BODY_NAME(1_1), in ATF_TC_BODY()
668 "1", "1", "1 != 1: 1 does not match 1", true }, in ATF_TC_BODY()
669 { H_REQUIRE_EQ_MSG_HEAD_NAME(1_2), H_REQUIRE_EQ_MSG_BODY_NAME(1_2), in ATF_TC_BODY()
670 "1", "2", "1 != 2: 1 does not match 2", false }, in ATF_TC_BODY()
671 { H_REQUIRE_EQ_MSG_HEAD_NAME(2_1), H_REQUIRE_EQ_MSG_BODY_NAME(2_1), in ATF_TC_BODY()
672 "2", "1", "2 != 1: 2 does not match 1", false }, in ATF_TC_BODY()
673 { H_REQUIRE_EQ_MSG_HEAD_NAME(2_2), H_REQUIRE_EQ_MSG_BODY_NAME(2_2), in ATF_TC_BODY()
674 "2", "2", "2 != 2: 2 does not match 2", true }, in ATF_TC_BODY()
680 H_REQUIRE_STREQ(1_1, "1", "1");
681 H_REQUIRE_STREQ(1_2, "1", "2");
682 H_REQUIRE_STREQ(2_1, "2", "1");
683 H_REQUIRE_STREQ(2_2, "2", "2");
684 H_REQUIRE_STREQ_MSG(1_1, "1", "1", "1 does not match 1");
685 H_REQUIRE_STREQ_MSG(1_2, "1", "2", "1 does not match 2");
686 H_REQUIRE_STREQ_MSG(2_1, "2", "1", "2 does not match 1");
687 H_REQUIRE_STREQ_MSG(2_2, "2", "2", "2 does not match 2");
703 { H_REQUIRE_STREQ_HEAD_NAME(1_1), H_REQUIRE_STREQ_BODY_NAME(1_1), in ATF_TC_BODY()
704 "1", "1", "\"1\" != \"1\" \\(1 != 1\\)", true }, in ATF_TC_BODY()
705 { H_REQUIRE_STREQ_HEAD_NAME(1_2), H_REQUIRE_STREQ_BODY_NAME(1_2), in ATF_TC_BODY()
706 "1", "2", "\"1\" != \"2\" \\(1 != 2\\)", false }, in ATF_TC_BODY()
707 { H_REQUIRE_STREQ_HEAD_NAME(2_1), H_REQUIRE_STREQ_BODY_NAME(2_1), in ATF_TC_BODY()
708 "2", "1", "\"2\" != \"1\" \\(2 != 1\\)", false }, in ATF_TC_BODY()
709 { H_REQUIRE_STREQ_HEAD_NAME(2_2), H_REQUIRE_STREQ_BODY_NAME(2_2), in ATF_TC_BODY()
710 "2", "2", "\"2\" != \"2\" \\(2 != 2\\)", true }, in ATF_TC_BODY()
711 { H_REQUIRE_STREQ_MSG_HEAD_NAME(1_1), in ATF_TC_BODY()
712 H_REQUIRE_STREQ_MSG_BODY_NAME(1_1), in ATF_TC_BODY()
713 "1", "1", "\"1\" != \"1\" \\(1 != 1\\): 1 does not match 1", true }, in ATF_TC_BODY()
714 { H_REQUIRE_STREQ_MSG_HEAD_NAME(1_2), in ATF_TC_BODY()
715 H_REQUIRE_STREQ_MSG_BODY_NAME(1_2), in ATF_TC_BODY()
716 "1", "2", "\"1\" != \"2\" \\(1 != 2\\): 1 does not match 2", false }, in ATF_TC_BODY()
717 { H_REQUIRE_STREQ_MSG_HEAD_NAME(2_1), in ATF_TC_BODY()
718 H_REQUIRE_STREQ_MSG_BODY_NAME(2_1), in ATF_TC_BODY()
719 "2", "1", "\"2\" != \"1\" \\(2 != 1\\): 2 does not match 1", false }, in ATF_TC_BODY()
720 { H_REQUIRE_STREQ_MSG_HEAD_NAME(2_2), in ATF_TC_BODY()
721 H_REQUIRE_STREQ_MSG_BODY_NAME(2_2), in ATF_TC_BODY()
722 "2", "2", "\"2\" != \"2\" \\(2 != 2\\): 2 does not match 2", true }, in ATF_TC_BODY()
732 /* ---------------------------------------------------------------------
734 * --------------------------------------------------------------------- */
736 H_REQUIRE_MATCH(yes, "hello [a-z]+", "abc hello world");
737 H_REQUIRE_MATCH(no, "hello [a-z]+", "abc hello WORLD");
738 H_REQUIRE_MATCH_MSG(yes, "hello [a-z]+", "abc hello world", "lowercase");
739 H_REQUIRE_MATCH_MSG(no, "hello [a-z]+", "abc hello WORLD", "uppercase");
751 "hello [a-z]+", "abc hello world", "", true }, in ATF_TC_BODY()
753 "hello [a-z]+", "abc hello WORLD", in ATF_TC_BODY()
754 "'hello \\[a-z\\]\\+' not matched in 'abc hello WORLD'", false }, in ATF_TC_BODY()
757 "hello [a-z]+", "abc hello world", "", true }, in ATF_TC_BODY()
759 "hello [a-z]+", "abc hello WORLD", in ATF_TC_BODY()
760 "'hello \\[a-z\\]\\+' not matched in 'abc hello WORLD': uppercase", in ATF_TC_BODY()
767 /* ---------------------------------------------------------------------
769 * --------------------------------------------------------------------- */
794 "as part of the automatically-generated messages " in ATF_TC_HEAD()
816 for (t = &tests[0]; t->head != NULL; t++) { in ATF_TC_BODY()
817 printf("Checking with an expected '%s' message\n", t->msg); in ATF_TC_BODY()
819 init_and_run_h_tc("h_check", t->head, t->body); in ATF_TC_BODY()
821 if (t->fatal) { in ATF_TC_BODY()
824 "^failed: .*macros_test.c:[0-9]+: %s$", "result", t->msg); in ATF_TC_BODY()
828 "macros_test.c:[0-9]+: %s$", "error", t->msg); in ATF_TC_BODY()
834 /* ---------------------------------------------------------------------
836 * --------------------------------------------------------------------- */
839 "Tests that the macros provided by the atf-c/macros.h file "
841 "Build of macros_h_test.c failed; some macros in atf-c/macros.h "
868 /* ---------------------------------------------------------------------
870 * --------------------------------------------------------------------- */