Changeset 9b20126 in mainline for uspace/lib/pcut/tests


Ignore:
Timestamp:
2014-09-19T08:23:01Z (11 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c85a57f
Parents:
15d0046
Message:

Update PCUT to newest version

Location:
uspace/lib/pcut/tests
Files:
8 added
3 edited
6 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/pcut/tests/abort.c

    r15d0046 r9b20126  
    2828
    2929#include <pcut/pcut.h>
    30 #include "tested.h"
     30#include <stdlib.h>
    3131
    3232PCUT_INIT
    3333
    3434PCUT_TEST(access_null_pointer) {
    35         int a = 5;
    36         int *p = &a;
    37         PCUT_ASSERT_INT_EQUALS(5, *p);
    38         p = NULL;
    39         PCUT_ASSERT_INT_EQUALS(5, *p);
     35        abort();
    4036}
    4137
  • uspace/lib/pcut/tests/beforeafter.c

    r15d0046 r9b20126  
    2727 */
    2828
     29#define _BSD_SOURCE
     30
    2931#include <pcut/pcut.h>
    3032#include <stdlib.h>
    3133#include <stdio.h>
     34
     35/*
     36 * Use sprintf_s in Windows but only with Microsoft compiler.
     37 * Namely, let MinGW use snprintf.
     38 */
     39#if (defined(__WIN64) || defined(__WIN32) || defined(_WIN32)) && defined(_MSC_VER)
     40#define snprintf sprintf_s
     41#endif
    3242
    3343PCUT_INIT
     
    3646#define BUFFER_SIZE 512
    3747
    38 PCUT_TEST_SUITE(suite_with_setup_and_teardown)
     48PCUT_TEST_SUITE(suite_with_setup_and_teardown);
    3949
    4050PCUT_TEST_BEFORE {
     
    4858}
    4959
    50 PCUT_TEST(snprintf) {
     60PCUT_TEST(test_with_setup_and_teardown) {
    5161        snprintf(buffer, BUFFER_SIZE - 1, "%d-%s", 56, "abcd");
    5262        PCUT_ASSERT_STR_EQUALS("56-abcd", buffer);
    5363}
    5464
    55 PCUT_TEST_SUITE(another_without_setup)
     65PCUT_TEST_SUITE(another_without_setup);
    5666
    57 PCUT_TEST(whatever) {
     67PCUT_TEST(test_without_any_setup_or_teardown) {
    5868        PCUT_ASSERT_NULL(buffer);
    5969}
  • uspace/lib/pcut/tests/beforeafter.expected

    r15d0046 r9b20126  
    111..2
    22#> Starting suite suite_with_setup_and_teardown.
    3 ok 1 snprintf
     3ok 1 test_with_setup_and_teardown
    44#> Finished suite suite_with_setup_and_teardown (failed 0 of 1).
    55#> Starting suite another_without_setup.
    6 ok 2 whatever
     6ok 2 test_without_any_setup_or_teardown
    77#> Finished suite another_without_setup (failed 0 of 1).
  • uspace/lib/pcut/tests/errno.expected

    r15d0046 r9b20126  
    22#> Starting suite Default.
    33not ok 1 errno_value failed
    4 # error: errno.c:46: Expected error 0 (EOK, Success) but got error 2 (No such file or directory)
     4# error: errno.c:46: Expected error 0 (EOK, *****) but got error ***** (*****)
    55not ok 2 errno_variable failed
    6 # error: errno.c:54: Expected error 0 (EOK, Success) but got error 2 (No such file or directory)
     6# error: errno.c:54: Expected error 0 (EOK, *****) but got error ***** (*****)
    77#> Finished suite Default (failed 2 of 2).
  • uspace/lib/pcut/tests/teardown.c

    r15d0046 r9b20126  
    5050
    5151
    52 PCUT_TEST_SUITE(with_failing_teardown)
     52PCUT_TEST_SUITE(with_failing_teardown);
    5353
    5454PCUT_TEST_AFTER {
  • uspace/lib/pcut/tests/teardownaborts.c

    r15d0046 r9b20126  
    2929#include <stdio.h>
    3030#include <pcut/pcut.h>
    31 #include "tested.h"
     31#include <stdlib.h>
    3232
    3333PCUT_INIT
    3434
    3535PCUT_TEST_AFTER {
    36         int a = 5;
    37         int *p = &a;
    38         PCUT_ASSERT_INT_EQUALS(5, *p);
    39         p = NULL;
    40         PCUT_ASSERT_INT_EQUALS(5, *p);
     36        abort();
    4137}
    4238
  • uspace/lib/pcut/tests/teardownaborts.expected

    r15d0046 r9b20126  
    22#> Starting suite Default.
    33not ok 1 print_and_fail aborted
    4 # error: nullteardown.c:45: Pointer <NULL> ought not to be NULL
     4# error: teardownaborts.c:41: Pointer <NULL> ought not to be NULL
    55# stdio: Tear-down will cause null pointer access...
    66#> Finished suite Default (failed 1 of 1).
  • uspace/lib/pcut/tests/timeout.c

    r15d0046 r9b20126  
    2828
    2929#include <pcut/pcut.h>
     30
     31#ifdef __unix
    3032#include <unistd.h>
     33#endif
     34#if defined(__WIN64) || defined(__WIN32) || defined(_WIN32)
     35#include <windows.h>
     36#endif
     37
    3138#include <stdio.h>
    3239#include "tested.h"
     40
     41static void my_sleep(int sec) {
     42#ifdef __unix
     43        sleep(sec);
     44#endif
     45#if defined(__WIN64) || defined(__WIN32) || defined(_WIN32)
     46        Sleep(1000 * sec);
     47#endif
     48}
    3349
    3450PCUT_INIT
     
    3652PCUT_TEST(shall_time_out) {
    3753        printf("Text before sleeping.\n");
    38         sleep(PCUT_DEFAULT_TEST_TIMEOUT * 5);
     54        my_sleep(PCUT_DEFAULT_TEST_TIMEOUT * 5);
    3955        printf("Text after the sleep.\n");
    4056}
     
    4359                PCUT_TEST_SET_TIMEOUT(PCUT_DEFAULT_TEST_TIMEOUT * 3)) {
    4460        printf("Text before sleeping.\n");
    45         sleep(PCUT_DEFAULT_TEST_TIMEOUT * 2);
     61        my_sleep(PCUT_DEFAULT_TEST_TIMEOUT * 2);
    4662        printf("Text after the sleep.\n");
    4763}
Note: See TracChangeset for help on using the changeset viewer.