1 /* 2 * Copyright © 2015 Samsung Electronics Co., Ltd 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining 5 * a copy of this software and associated documentation files (the 6 * "Software"), to deal in the Software without restriction, including 7 * without limitation the rights to use, copy, modify, merge, publish, 8 * distribute, sublicense, and/or sell copies of the Software, and to 9 * permit persons to whom the Software is furnished to do so, subject to 10 * the following conditions: 11 * 12 * The above copyright notice and this permission notice (including the 13 * next paragraph) shall be included in all copies or substantial 14 * portions of the Software. 15 * 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 21 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 * SOFTWARE. 24 */ 25 26 #ifndef Z_UNIT_C_H 27 #define Z_UNIT_C_H 28 29 #include <limits.h> 30 #include <stdarg.h> 31 #include <stdbool.h> 32 #include <stdint.h> 33 34 #include "zunitc/zunitc_impl.h" 35 36 #if !__GNUC__ 37 #error Framework currently requires gcc or compatible compiler. 38 #endif 39 40 #if INTPTR_MAX < INT_MAX 41 #error Odd platform requires rework of value type from intptr_t to custom. 42 #endif 43 44 /** 45 * @file 46 * Simple unit test framework declarations. 47 */ 48 49 #ifdef __cplusplus 50 extern "C" { 51 #endif 52 53 /** 54 * @page zunitc 55 */ 56 57 /** 58 * Structure to use when defining a test fixture. 59 * @note likely pending refactoring as use cases are refined. 60 * @see ZUC_TEST_F() 61 */ 62 struct zuc_fixture { 63 /** 64 * Initial optional seed data to pass to setup functions and/or tests. 65 */ 66 const void *data; 67 68 /** 69 * Per-suite setup called before invoking any of the tests 70 * contained in the suite. 71 * 72 * @return a pointer to test data, or NULL. 73 */ 74 void *(*set_up_test_case)(const void *data); 75 76 /** 77 * Per-suite tear-down called after invoking all of the tests 78 * contained in the suite. 79 * 80 * @param data pointer returned from the setup function. 81 */ 82 void (*tear_down_test_case)(void *data); 83 84 /** 85 * Setup called before running each of the tests in the suite. 86 * 87 * @param data optional data from suite setup, or NULL. 88 * @return a pointer to test data, or NULL. 89 */ 90 void *(*set_up)(void *data); 91 92 /** 93 * Tear-down called after running each of the tests in the suite. 94 * 95 * @param data pointer returned from the setup function. 96 */ 97 void (*tear_down)(void *data); 98 }; 99 100 /** 101 * Process exit code to mark skipped tests, consistent with 102 * automake tests. 103 */ 104 #define ZUC_EXIT_SKIP 77 105 106 /** 107 * Accesses the test executable program name. 108 * This version will include any full or partial path used to 109 * launch the executable. 110 * 111 * @note This depends on zuc_initialize() having been called. 112 * 113 * @return the name of the running program. 114 * The caller should not free nor hold this pointer. It will not stay 115 * valid across calls to zuc_initialize() or zuc_cleanup(). 116 * @see zuc_get_program_basename() 117 */ 118 const char * 119 zuc_get_program_name(void); 120 121 /** 122 * Accesses the test executable program name in trimmed format. 123 * If the program is launched via a partial or full path, this 124 * version trims to return only the basename. 125 * 126 * @note This depends on zuc_initialize() having been called. 127 * 128 * @return the name of the running program. 129 * The caller should not free nor hold this pointer. It will not stay 130 * valid across calls to zuc_initialize() or zuc_cleanup(). 131 * @see zuc_get_program_name() 132 */ 133 const char * 134 zuc_get_program_basename(void); 135 136 /** 137 * Initializes the test framework and consumes any known command-line 138 * parameters from the list. 139 * The exception is 'h/help' which will be left in place for follow-up 140 * processing by the hosting app if so desired. 141 * 142 * @param argc pointer to argc value to read and possibly change. 143 * @param argv array of parameter pointers to read and possibly change. 144 * @param help_flagged if non-NULL will be set to true if the user 145 * specifies the help flag (and framework help has been output). 146 * @return EXIT_SUCCESS upon success setting or help, EXIT_FAILURE otherwise. 147 */ 148 int zuc_initialize(int *argc, char *argv[], bool *help_flagged); 149 150 /** 151 * Runs all tests that have been registered. 152 * Expected return values include EXIT_FAILURE if any errors or failures 153 * have occurred, ::ZUC_EXIT_SKIP if no failures have occurred but at least 154 * one test reported skipped, otherwise EXIT_SUCCESS if nothing of note 155 * was recorded. 156 * 157 * @note for consistency with other frameworks and to allow for additional 158 * cleanup to be added later this is implemented as a wrapper macro. 159 * 160 * @return expected exit status - normally EXIT_SUCCESS, ::ZUC_EXIT_SKIP, 161 * or EXIT_FAILURE. 162 * Normally an application can use this value directly in calling exit(), 163 * however there could be cases where some additional processing such as 164 * resource cleanup or library shutdown that a program might want to do 165 * first. 166 */ 167 #define ZUC_RUN_TESTS() \ 168 zucimpl_run_tests() 169 170 /** 171 * Clears the test system in preparation for application shutdown. 172 */ 173 void 174 zuc_cleanup(void); 175 176 /** 177 * Displays all known tests. 178 * The list returned is affected by any filtering in place. 179 * 180 * @see zuc_set_filter() 181 */ 182 void 183 zuc_list_tests(void); 184 185 /** 186 * Sets the filter string to use for tests. 187 * The format is a series of patterns separated by a colon, with wildcards 188 * and an optional flag for negative matching. For wildcards, the '*' 189 * character will match any sequence and the '?' character will match any 190 * single character. 191 * The '-' character at the start of a pattern marks the end of the 192 * patterns required to match and the beginning of patterns that names 193 * must not match. 194 * Defaults to use all tests. 195 * 196 * @param filter the filter string to apply to tests. 197 */ 198 void 199 zuc_set_filter(const char *filter); 200 201 /** 202 * Trigger specific failure/signal upon test failures; useful when 203 * running under a debugger. 204 * Currently this is implemented to raise a SIGABRT signal when any 205 * failure is reported. 206 * Defaults to false. 207 * 208 * @param break_on_failure true to cause a break when tests fail, false to 209 * allow normal operation upon failures. 210 */ 211 void 212 zuc_set_break_on_failure(bool break_on_failure); 213 214 /** 215 * Sets the number of times to repeat the tests. 216 * Any number higher than 1 will cause the tests to be repeated the 217 * specified number of times. 218 * Defaults to 1/no repeating. 219 * 220 * @param repeat number of times to repeat the tests. 221 */ 222 void 223 zuc_set_repeat(int repeat); 224 225 /** 226 * Randomizes the order in which tests are executed. 227 * A value of 0 (the default) means tests are executed in their natural 228 * ordering. A value of 1 will pick a random seed based on the time to 229 * use for running tests in a pseudo-random order. A value greater than 1 230 * will be used directly for the initial seed. 231 * 232 * If the tests are also repeated, the seed will be incremented for each 233 * subsequent run. 234 * Defaults to 0/not randomize. 235 * 236 * @param random 0|1|seed value. 237 * @see zuc_set_repeat() 238 */ 239 void 240 zuc_set_random(int random); 241 242 /** 243 * Controls whether or not to run the tests as forked child processes. 244 * Defaults to true. 245 * 246 * @param spawn true to spawn each test in a forked child process, 247 * false to run tests directly. 248 */ 249 void 250 zuc_set_spawn(bool spawn); 251 252 /** 253 * Enables output in the JUnit XML format. 254 * Defaults to false. 255 * 256 * @param enable true to generate JUnit XML output, false to disable. 257 */ 258 void 259 zuc_set_output_junit(bool enable); 260 261 /** 262 * Defines a test case that can be registered to run. 263 * 264 * @param tcase name to use as the containing test case. 265 * @param test name used for the test under a given test case. 266 */ 267 #define ZUC_TEST(tcase, test) \ 268 static void zuctest_##tcase##_##test(void); \ 269 \ 270 const struct zuc_registration zzz_##tcase##_##test \ 271 __attribute__ ((used, section ("zuc_tsect"))) = \ 272 { \ 273 #tcase, #test, 0, \ 274 zuctest_##tcase##_##test, \ 275 0 \ 276 }; \ 277 \ 278 static void zuctest_##tcase##_##test(void) 279 280 /** 281 * Defines a test case that can be registered to run along with setup/teardown 282 * support per-test and/or per test case. 283 * 284 * @note This defines a test that *uses* a fixture, it does not 285 * actually define a test fixture itself. 286 * 287 * @param tcase name to use as the containing test case/fixture. 288 * The name used must represent a test fixture instance. It also 289 * must not duplicate any name used in a non-fixture ZUC_TEST() 290 * test. 291 * @note the test case name must be the name of a fixture struct 292 * to be passed to the test. 293 * @param test name used for the test under a given test case. 294 * @param param name for the fixture data pointer. 295 * @see struct zuc_fixture 296 */ 297 #define ZUC_TEST_F(tcase, test, param) \ 298 static void zuctest_##tcase##_##test(void *param); \ 299 \ 300 const struct zuc_registration zzz_##tcase##_##test \ 301 __attribute__ ((used, section ("zuc_tsect"))) = \ 302 { \ 303 #tcase, #test, &tcase, \ 304 0, \ 305 zuctest_##tcase##_##test \ 306 }; \ 307 \ 308 static void zuctest_##tcase##_##test(void *param) 309 310 311 /** 312 * Returns true if the currently executing test has encountered any skips. 313 * 314 * @return true if there is currently a test executing and it has 315 * encountered any skips. 316 * @see zuc_has_failure 317 * @see ZUC_SKIP() 318 */ 319 bool 320 zuc_has_skip(void); 321 322 /** 323 * Returns true if the currently executing test has encountered any failures. 324 * 325 * @return true if there is currently a test executing and it has 326 * encountered any failures. 327 * @see zuc_has_skip 328 */ 329 bool 330 zuc_has_failure(void); 331 332 /** 333 * Marks the running test as skipped without marking it as failed, and returns 334 * from the current function. 335 * 336 * For details on return and test termination see @ref zunitc_overview_return. 337 * 338 * @param message the message to log as to why the test has been skipped. 339 */ 340 #define ZUC_SKIP(message) \ 341 do { \ 342 zucimpl_terminate(__FILE__, __LINE__, false, false, #message); \ 343 return; \ 344 } \ 345 while (0) 346 347 /** 348 * Marks the running test as failed and returns from the current function. 349 * 350 * For details on return and test termination see @ref zunitc_overview_return. 351 * 352 * @param message the message to log as to why the test has failed. 353 */ 354 #define ZUC_FATAL(message) \ 355 do { \ 356 zucimpl_terminate(__FILE__, __LINE__, true, true, #message); \ 357 return; \ 358 } \ 359 while (0) 360 361 /** 362 * Marks the current test as failed with a fatal issue, but does not 363 * immediately return from the current function. ZUC_FATAL() is normally 364 * preferred, but when further cleanup is needed, or the current function 365 * needs to return a value, this macro may be required. 366 * 367 * @param message the message to log as to why the test has failed. 368 * @see ZUC_FATAL() 369 */ 370 #define ZUC_MARK_FATAL(message) \ 371 do { \ 372 zucimpl_terminate(__FILE__, __LINE__, true, true, #message); \ 373 } \ 374 while (0) 375 376 /** 377 * Creates a message that will be processed in the case of failure. 378 * If the test encounters any failures (fatal or non-fatal) then these 379 * messages are included in output. Otherwise they are discarded at the 380 * end of the test run. 381 * 382 * @param message the format string style message. 383 */ 384 #define ZUC_TRACEPOINT(message, ...) \ 385 zucimpl_tracepoint(__FILE__, __LINE__, message, ##__VA_ARGS__); 386 387 /** 388 * Internal use macro for ASSERT implementation. 389 * Should not be used directly in code. 390 */ 391 #define ZUCIMPL_ASSERT(opcode, valtype, lhs, rhs) \ 392 do { \ 393 if (zucimpl_expect_pred2(__FILE__, __LINE__, \ 394 (opcode), (valtype), true, \ 395 (intptr_t)(lhs), (intptr_t)(rhs), \ 396 #lhs, #rhs)) { \ 397 return; \ 398 } \ 399 } \ 400 while (0) 401 402 /** 403 * Internal use macro for ASSERT with Goto implementation. 404 * Should not be used directly in code. 405 */ 406 #define ZUCIMPL_ASSERTG(label, opcode, valtype, lhs, rhs) \ 407 do { \ 408 if (zucimpl_expect_pred2(__FILE__, __LINE__, \ 409 (opcode), (valtype), true, \ 410 (intptr_t)(lhs), (intptr_t)(rhs), \ 411 #lhs, #rhs)) { \ 412 goto label; \ 413 } \ 414 } \ 415 while (0) 416 417 /** 418 * Verifies that the specified expression is true, marks the test as failed 419 * and exits the current function via 'return' if it is not. 420 * 421 * For details on return and test termination see @ref zunitc_overview_return. 422 * 423 * @param condition the expression that is expected to be true. 424 * @note it is far better to use a more specific check when possible 425 * (e.g. ZUC_ASSERT_EQ(), ZUC_ASSERT_NE(), etc.) 426 * @see ZUC_ASSERTG_TRUE() 427 */ 428 #define ZUC_ASSERT_TRUE(condition) \ 429 ZUCIMPL_ASSERT(ZUC_OP_TRUE, ZUC_VAL_INT, condition, 0) 430 431 /** 432 * Verifies that the specified expression is false, marks the test as 433 * failed and exits the current function via 'return' if it is not. 434 * 435 * For details on return and test termination see @ref zunitc_overview_return. 436 * 437 * @param condition the expression that is expected to be false. 438 * @note it is far better to use a more specific check when possible 439 * (e.g. ZUC_ASSERT_EQ(), ZUC_ASSERT_NE(), etc.) 440 * @see ZUC_ASSERTG_FALSE() 441 */ 442 #define ZUC_ASSERT_FALSE(condition) \ 443 ZUCIMPL_ASSERT(ZUC_OP_FALSE, ZUC_VAL_INT, condition, 0) 444 445 /** 446 * Verifies that the specified expression is NULL, marks the test as failed 447 * and exits the current function via 'return' if it is not. 448 * 449 * For details on return and test termination see @ref zunitc_overview_return. 450 * 451 * @param condition the expression that is expected to be a NULL pointer. 452 * @see ZUC_ASSERTG_NULL() 453 */ 454 #define ZUC_ASSERT_NULL(condition) \ 455 ZUCIMPL_ASSERT(ZUC_OP_NULL, ZUC_VAL_PTR, condition, 0) 456 457 /** 458 * Verifies that the specified expression is non-NULL, marks the test as 459 * failed and exits the current function via 'return' if it is not. 460 * 461 * For details on return and test termination see @ref zunitc_overview_return. 462 * 463 * @param condition the expression that is expected to be a non-NULL pointer. 464 * @see ZUC_ASSERTG_NOT_NULL() 465 */ 466 #define ZUC_ASSERT_NOT_NULL(condition) \ 467 ZUCIMPL_ASSERT(ZUC_OP_NOT_NULL, ZUC_VAL_PTR, condition, 0) 468 469 /** 470 * Verifies that the values of the specified expressions match, marks the 471 * test as failed and exits the current function via 'return' if they do not. 472 * 473 * For details on return and test termination see @ref zunitc_overview_return. 474 * 475 * @param expected the value the result should hold. 476 * @param actual the actual value seen in testing. 477 * @see ZUC_ASSERTG_EQ() 478 */ 479 #define ZUC_ASSERT_EQ(expected, actual) \ 480 ZUCIMPL_ASSERT(ZUC_OP_EQ, ZUC_VAL_INT, expected, actual) 481 482 /** 483 * Verifies that the values of the specified expressions differ, marks the 484 * test as failed and exits the current function via 'return' if they do not. 485 * 486 * For details on return and test termination see @ref zunitc_overview_return. 487 * 488 * @param expected the value the result should not hold. 489 * @param actual the actual value seen in testing. 490 * @see ZUC_ASSERTG_NE() 491 */ 492 #define ZUC_ASSERT_NE(expected, actual) \ 493 ZUCIMPL_ASSERT(ZUC_OP_NE, ZUC_VAL_INT, expected, actual) 494 495 /** 496 * Verifies that the value of the first expression is less than the value 497 * of the second expression, marks the test as failed and exits the current 498 * function via 'return' if it is not. 499 * 500 * For details on return and test termination see @ref zunitc_overview_return. 501 * 502 * @param lesser the expression whose value should be lesser than the other. 503 * @param greater the expression whose value should be greater than the other. 504 * @see ZUC_ASSERTG_LT() 505 */ 506 #define ZUC_ASSERT_LT(lesser, greater) \ 507 ZUCIMPL_ASSERT(ZUC_OP_LT, ZUC_VAL_INT, lesser, greater) 508 509 /** 510 * Verifies that the value of the first expression is less than or equal 511 * to the value of the second expression, marks the test as failed and 512 * exits the current function via 'return' if it is not. 513 * 514 * For details on return and test termination see @ref zunitc_overview_return. 515 * 516 * @param lesser the expression whose value should be lesser than or equal to 517 * the other. 518 * @param greater the expression whose value should be greater than or equal to 519 * the other. 520 * @see ZUC_ASSERTG_LE() 521 */ 522 #define ZUC_ASSERT_LE(lesser, greater) \ 523 ZUCIMPL_ASSERT(ZUC_OP_LE, ZUC_VAL_INT, lesser, greater) 524 525 /** 526 * Verifies that the value of the first expression is greater than the 527 * value of the second expression, marks the test as failed and exits the 528 * current function via 'return' if it is not. 529 * 530 * For details on return and test termination see @ref zunitc_overview_return. 531 * 532 * @param greater the expression whose value should be greater than the other. 533 * @param lesser the expression whose value should be lesser than the other. 534 * @see ZUC_ASSERTG_GT() 535 */ 536 #define ZUC_ASSERT_GT(greater, lesser) \ 537 ZUCIMPL_ASSERT(ZUC_OP_GT, ZUC_VAL_INT, greater, lesser) 538 539 /** 540 * Verifies that the value of the first expression is greater than or equal 541 * to the value of the second expression, marks the test as failed and exits 542 * the current function via 'return' if it is not. 543 * 544 * For details on return and test termination see @ref zunitc_overview_return. 545 * 546 * @param greater the expression whose value should be greater than or equal to 547 * the other. 548 * @param lesser the expression whose value should be lesser than or equal to 549 * the other. 550 * @see ZUC_ASSERTG_GE() 551 */ 552 #define ZUC_ASSERT_GE(greater, lesser) \ 553 ZUCIMPL_ASSERT(ZUC_OP_GE, ZUC_VAL_INT, greater, lesser) 554 555 /** 556 * Verifies that the values of the specified expressions match when 557 * compared as null-terminated C-style strings, marks the test as failed 558 * and exits the current function via 'return' if they do not. 559 * 560 * For details on return and test termination see @ref zunitc_overview_return. 561 * 562 * @param expected the value the result should hold. 563 * @param actual the actual value seen in testing. 564 * @see ZUC_ASSERTG_STREQ() 565 */ 566 #define ZUC_ASSERT_STREQ(expected, actual) \ 567 ZUCIMPL_ASSERT(ZUC_OP_EQ, ZUC_VAL_CSTR, expected, actual) 568 569 /** 570 * Verifies that the values of the specified expressions differ when 571 * compared as null-terminated C-style strings, marks the test as failed 572 * and exits the current function via 'return' if they do not. 573 * 574 * For details on return and test termination see @ref zunitc_overview_return. 575 * 576 * @param expected the value the result should not hold. 577 * @param actual the actual value seen in testing. 578 * @see ZUC_ASSERTG_STRNE() 579 */ 580 #define ZUC_ASSERT_STRNE(expected, actual) \ 581 ZUCIMPL_ASSERT(ZUC_OP_NE, ZUC_VAL_CSTR, expected, actual) 582 583 /** 584 * Verifies that the specified expression is true, marks the test as failed 585 * and interrupts the current execution via a 'goto' if it is not. 586 * 587 * @param condition the expression that is expected to be true. 588 * @note it is far better to use a more specific check when possible 589 * (e.g. ZUC_ASSERTG_EQ(), ZUC_ASSERTG_NE(), etc.) 590 * @param label the target for 'goto' if the assertion fails. 591 * @see ZUC_ASSERT_TRUE() 592 */ 593 #define ZUC_ASSERTG_TRUE(condition, label) \ 594 ZUCIMPL_ASSERTG(label, ZUC_OP_TRUE, ZUC_VAL_INT, condition, 0) 595 596 /** 597 * Verifies that the specified expression is false, marks the test as 598 * failed and interrupts the current execution via a 'goto' if it is not. 599 * 600 * @param condition the expression that is expected to be false. 601 * @note it is far better to use a more specific check when possible 602 * (e.g. ZUC_ASSERTG_EQ(), ZUC_ASSERTG_NE(), etc.) 603 * @param label the target for 'goto' if the assertion fails. 604 * @see ZUC_ASSERT_FALSE() 605 */ 606 #define ZUC_ASSERTG_FALSE(condition, label) \ 607 ZUCIMPL_ASSERTG(label, ZUC_OP_FALSE, ZUC_VAL_INT, condition, 0) 608 609 /** 610 * Verifies that the specified expression is NULL, marks the test as failed 611 * and interrupts the current execution via a 'goto' if it is not. 612 * 613 * @param condition the expression that is expected to be a NULL pointer. 614 * @param label the target for 'goto' if the assertion fails. 615 * @see ZUC_ASSERT_NULL() 616 */ 617 #define ZUC_ASSERTG_NULL(condition, label) \ 618 ZUCIMPL_ASSERTG(label, ZUC_OP_NULL, ZUC_VAL_PTR, condition, 0) 619 620 /** 621 * Verifies that the specified expression is non-NULL, marks the test as 622 * failed and interrupts the current execution via a 'goto' if it is not. 623 * 624 * @param condition the expression that is expected to be a non-NULL pointer. 625 * @param label the target for 'goto' if the assertion fails. 626 * @see ZUC_ASSERT_NOT_NULL() 627 */ 628 #define ZUC_ASSERTG_NOT_NULL(condition, label) \ 629 ZUCIMPL_ASSERTG(label, ZUC_OP_NOT_NULL, ZUC_VAL_PTR, condition, 0) 630 631 /** 632 * Verifies that the values of the specified expressions match, marks the 633 * test as failed and interrupts the current execution via a 'goto' if they 634 * do not. 635 * 636 * @param expected the value the result should hold. 637 * @param actual the actual value seen in testing. 638 * @param label the target for 'goto' if the assertion fails. 639 * @see ZUC_ASSERT_EQ() 640 */ 641 #define ZUC_ASSERTG_EQ(expected, actual, label) \ 642 ZUCIMPL_ASSERTG(label, ZUC_OP_EQ, ZUC_VAL_INT, expected, actual) 643 644 /** 645 * Verifies that the values of the specified expressions differ, marks the 646 * test as failed and interrupts the current execution via a 'goto' if they 647 * do not. 648 * 649 * @param expected the value the result should not hold. 650 * @param actual the actual value seen in testing. 651 * @param label the target for 'goto' if the assertion fails. 652 * @see ZUC_ASSERT_NE() 653 */ 654 #define ZUC_ASSERTG_NE(expected, actual, label) \ 655 ZUCIMPL_ASSERTG(label, ZUC_OP_NE, ZUC_VAL_INT, expected, actual) 656 657 /** 658 * Verifies that the value of the first expression is less than the value 659 * of the second expression, marks the test as failed and interrupts the 660 * current execution via a 'goto' if it is not. 661 * 662 * @param lesser the expression whose value should be lesser than the other. 663 * @param greater the expression whose value should be greater than the other. 664 * @param label the target for 'goto' if the assertion fails. 665 * @see ZUC_ASSERT_LT() 666 */ 667 #define ZUC_ASSERTG_LT(lesser, greater, label) \ 668 ZUCIMPL_ASSERTG(label, ZUC_OP_LT, ZUC_VAL_INT, lesser, greater) 669 670 /** 671 * Verifies that the value of the first expression is less than or equal 672 * to the value of the second expression, marks the test as failed and 673 * interrupts the current execution via a 'goto' if it is not. 674 * 675 * @param lesser the expression whose value should be lesser than or equal to 676 * the other. 677 * @param greater the expression whose value should be greater than or equal to 678 * the other. 679 * @param label the target for 'goto' if the assertion fails. 680 * @see ZUC_ASSERT_LE() 681 */ 682 #define ZUC_ASSERTG_LE(lesser, greater, label) \ 683 ZUCIMPL_ASSERTG(label, ZUC_OP_LE, ZUC_VAL_INT, lesser, greater) 684 685 /** 686 * Verifies that the value of the first expression is greater than the 687 * value of the second expression, marks the test as failed and interrupts the 688 * current execution via a 'goto' if it is not. 689 * 690 * @param greater the expression whose value should be greater than the other. 691 * @param lesser the expression whose value should be lesser than the other. 692 * @param label the target for 'goto' if the assertion fails. 693 * @see ZUC_ASSERT_GT() 694 */ 695 #define ZUC_ASSERTG_GT(greater, lesser, label) \ 696 ZUCIMPL_ASSERTG(label, ZUC_OP_GT, ZUC_VAL_INT, greater, lesser) 697 698 /** 699 * Verifies that the value of the first expression is greater than or equal 700 * to the value of the second expression, marks the test as failed and 701 * interrupts the current execution via a 'goto' if it is not. 702 * 703 * @param greater the expression whose value should be greater than or equal to 704 * the other. 705 * @param lesser the expression whose value should be lesser than or equal to 706 * the other. 707 * @param label the target for 'goto' if the assertion fails. 708 * @see ZUC_ASSERT_GE() 709 */ 710 #define ZUC_ASSERTG_GE(greater, lesser, label) \ 711 ZUCIMPL_ASSERTG(label, ZUC_OP_GE, ZUC_VAL_INT, greater, lesser) 712 713 /** 714 * Verifies that the values of the specified expressions match when 715 * compared as null-terminated C-style strings, marks the test as failed 716 * and interrupts the current execution via a 'goto' if they do not. 717 * 718 * @param expected the value the result should hold. 719 * @param actual the actual value seen in testing. 720 * @param label the target for 'goto' if the assertion fails. 721 * @see ZUC_ASSERT_STREQ() 722 */ 723 #define ZUC_ASSERTG_STREQ(expected, actual, label) \ 724 ZUCIMPL_ASSERTG(label, ZUC_OP_EQ, ZUC_VAL_CSTR, expected, actual) 725 726 /** 727 * Verifies that the values of the specified expressions differ when 728 * compared as null-terminated C-style strings, marks the test as failed 729 * and interrupts the current execution via a 'goto' if they do not. 730 * 731 * @param expected the value the result should not hold. 732 * @param actual the actual value seen in testing. 733 * @param label the target for 'goto' if the assertion fails. 734 * @see ZUC_ASSERT_STRNE() 735 */ 736 #define ZUC_ASSERTG_STRNE(expected, actual, label) \ 737 ZUCIMPL_ASSERTG(label, ZUC_OP_NE, ZUC_VAL_CSTR, expected, actual) 738 739 #ifdef __cplusplus 740 } /* extern "C" */ 741 #endif 742 743 #endif /* Z_UNIT_C_H */ 744