Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 134ac5d in mainline


Ignore:
Timestamp:
2014-06-06T07:54:24Z (6 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
master
Children:
8db09e4
Parents:
eeb23f2d
Message:

Update PCUT to newest version

Location:
uspace
Files:
13 added
2 deleted
34 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/bdsh/test/toktest.c

    reeb23f2d r134ac5d  
    3232
    3333#include "../tok.h"
    34 #include <pcut/test.h>
     34#include <pcut/pcut.h>
    3535
    3636PCUT_INIT
  • uspace/lib/c/test/main.c

    reeb23f2d r134ac5d  
    2828
    2929#include <stdio.h>
    30 #include <pcut/test.h>
     30#include <pcut/pcut.h>
    3131
    3232PCUT_INIT
  • uspace/lib/c/test/sprintf.c

    reeb23f2d r134ac5d  
    2828
    2929#include <stdio.h>
    30 #include <pcut/test.h>
     30#include <pcut/pcut.h>
    3131
    3232#define BUFFER_SIZE 8192
  • uspace/lib/pcut/README.rst

    reeb23f2d r134ac5d  
    2222safe against unexpected crashes, such as null pointer dereference.
    2323
    24 More details can be found on PCUT wiki on GitHub.
    25 
    26                                         https://github.com/vhotspur/pcut/wiki
     24More details can be found on PCUT wiki on GitHub:
     25https://github.com/vhotspur/pcut/wiki
    2726
    2827
    29 Main goal - simple to use
    30 -------------------------
     28Quick-start example
     29-------------------
    3130
    32 Let's illustrate how PCUT aims to be simple when creating unit tests for
    33 function ``intmin`` that ought to return smaller of its two arguments.::
     31The following code tests the standard ``atoi`` function::
    3432
    35         int intmin(int a, int b) {
    36                 return a > b ? b : a;
     33        #include <pcut/pcut.h>
     34        #include <stdlib.h>
     35       
     36        PCUT_INIT
     37       
     38        PCUT_TEST(atoi_zero) {
     39            PCUT_ASSERT_INT_EQUALS(0, atoi("0"));
    3740        }
    3841       
    39 Individual test-cases for such method could cover following cases: getting
    40 minimal of
    41 
    42 - two same numbers
    43 - negative and positive number
    44 - two negative numbers
    45 - two positive numbers
    46 - "corner case" numbers, such as minimal and maximal represented number
    47 
    48 In PCUT, that would be translated to the following code:::
    49 
    50         #include <pcut/test.h>
    51         #include <limits.h>
    52         /* Other include to have declaration of intmin */
    53        
    54         PCUT_INIT
    55 
    56         PCUT_TEST_SUITE(intmin_tests);
    57 
    58         PCUT_TEST(same_number) {
    59                 PCUT_ASSERT_INT_EQUALS(719, intmin(719, 719) );
    60                 PCUT_ASSERT_INT_EQUALS(-4589, intmin(-4589, -4589) );
     42        PCUT_TEST(atoi_positive) {
     43            PCUT_ASSERT_INT_EQUALS(42, atoi("42"));
    6144        }
    6245       
    63         PCUT_TEST(positive_and_negative) {
    64                 PCUT_ASSERT_INT_EQUALS(-5, intmin(-5, 71) );
    65                 PCUT_ASSERT_INT_EQUALS(-17, intmin(423, -17) );
     46        PCUT_TEST(atoi_negative) {
     47            PCUT_ASSERT_INT_EQUALS(-273, atoi("-273"));
    6648        }
    6749       
    68         PCUT_TEST(same_sign) {
    69                 PCUT_ASSERT_INT_EQUALS(22, intmin(129, 22) );
    70                 PCUT_ASSERT_INT_EQUALS(-37, intmin(-37, -1) );
    71         }
    72        
    73         PCUT_TEST(corner_cases) {
    74                 PCUT_ASSERT_INT_EQUALS(INT_MIN, intmin(INT_MIN, -1234) );
    75                 PCUT_ASSERT_INT_EQUALS(9876, intmin(9876, INT_MAX) );
    76         }
    77 
    7850        PCUT_MAIN()
    7951
    80 And that's all.
    81 You do not need to manually specify which tests to run etc.,
    82 everything is done magically via the ``PCUT_INIT``, ``PCUT_MAIN`` and
    83 ``PCUT_TEST`` macros.
    84 All you need to do is to compile this code and link it with ``libpcut``.
    85 Result of the linking would be an executable that runs the tests and
    86 reports the results.
     52As you can see, there is no manual listing of tests that form the test
     53suite etc, only the tests and ``PCUT_INIT`` at the beginning and
     54``PCUT_MAIN`` at the end.
    8755
    88 
    89 Examples
    90 --------
     56This code has to be linked with ``libpcut`` to get an executable that runs
     57the tests and reports the results.
    9158
    9259More examples, in the form of self-tests, are available in the ``tests/``
    9360subdirectory.
     61Other examples can be found on the Wiki.
    9462
    9563
  • uspace/lib/pcut/base.mak

    reeb23f2d r134ac5d  
    3131PCUT_CFLAGS = -Wall -Wextra -std=c99 -Werror -I$(PCUT_INCLUDE)
    3232
     33PCUT_PREPROC_SOURCES = \
     34        src/preproc.c
     35
    3336PCUT_SOURCES = \
    3437        src/assert.c \
  • uspace/lib/pcut/include/pcut/prevs.h

    reeb23f2d r134ac5d  
    11/*
    2  * Copyright (c) 2012-2013 Vojtech Horky
     2 * Copyright (c) 2012-2014 Vojtech Horky
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 #if !defined(PCUT_TEST_H_GUARD) && !defined(PCUT_INTERNAL)
    30 #error "You cannot include this file directly."
    31 #endif
     29/**
     30 * @file
     31 * Counter macros internally used by PCUT.
     32 */
    3233
    3334#ifndef PCUT_PREVS_H_GUARD
    3435#define PCUT_PREVS_H_GUARD
     36
     37#ifndef PCUT_DOXYGEN_IS_RUNNING
     38/** @cond devel */
    3539
    3640#define PCUT_PREV_1 0
     
    335339#define PCUT_PREV_300 299
    336340
     341/** @endcond */
     342
    337343#endif
    338344
     345#endif
     346
  • uspace/lib/pcut/pcut.mak

    reeb23f2d r134ac5d  
    2929-include base.mak
    3030
    31 all: $(PCUT_LIB)
     31all: $(PCUT_LIB) $(PCUT_PREPROC)
    3232
    3333pcut-clean: check-clean platform-clean
     
    3535
    3636%.o: %.c
     37
     38src/%.o: src/%.c
    3739        $(CC) -c -o $@ $(PCUT_CFLAGS) $<
     40
     41doxygen:
     42        doxygen doc/Doxyfile.devel
     43        doxygen doc/Doxyfile.user
  • uspace/lib/pcut/src/internal.h

    reeb23f2d r134ac5d  
    2727 */
    2828
     29/** @file
     30 * Common definitions internally used in PCUT.
     31 */
     32
    2933#ifndef PCUT_INTERNAL_H_GUARD
    3034#define PCUT_INTERNAL_H_GUARD
    3135
    32 #include <pcut/test.h>
     36#include <pcut/pcut.h>
    3337#include <stdlib.h>
    3438
     
    6973pcut_item_t *pcut_get_real_next(pcut_item_t *item);
    7074pcut_item_t *pcut_get_real(pcut_item_t *item);
    71 const char* pcut_run_test(pcut_test_func_t function);
    72 const char* pcut_run_setup_teardown(pcut_setup_func_t function);
    7375void pcut_print_tests(pcut_item_t *first);
    7476int pcut_is_arg_with_number(const char *arg, const char *opt, int *value);
     
    7880int pcut_run_test_single(pcut_item_t *test);
    7981
    80 extern pcut_item_t *pcut_current_test;
    81 extern pcut_item_t *pcut_current_suite;
    82 extern int pcut_running_test_now;
    83 extern int pcut_running_setup_now;
     82int pcut_get_test_timeout(pcut_item_t *test);
    8483
     84void pcut_failed_assertion(const char *message);
    8585void pcut_print_fail_message(const char *msg);
    8686
     87/** Reporting callbacks structure. */
    8788typedef struct pcut_report_ops pcut_report_ops_t;
    88 /** Reporting callbacks structure. */
     89
     90/** @copydoc pcut_report_ops_t */
    8991struct pcut_report_ops {
    9092        /** Initialize the reporting, given all tests. */
     
    116118void pcut_report_done(void);
    117119
     120/* OS-dependent functions. */
    118121
     122/** Tell whether two strings start with the same prefix.
     123 *
     124 * @param a First string.
     125 * @param b Second string.
     126 * @param len Length of common prefix.
     127 * @return Whether first @p len characters of @p a are the same as in @p b.
     128 */
    119129int pcut_str_start_equals(const char *a, const char *b, int len);
     130
     131/** Get size of string in bytes.
     132 *
     133 * @param s String in question.
     134 * @return Size of @p s in bytes.
     135 */
    120136int pcut_str_size(const char *s);
     137
     138/** Convert string to integer.
     139 *
     140 * @param s String with integer.
     141 * @return Converted integer.
     142 */
    121143int pcut_str_to_int(const char *s);
     144
     145/** Find character in a string.
     146 *
     147 * @param haystack Where to look for the @p needle.
     148 * @param needle Character to find.
     149 * @return String starting with @p needle.
     150 * @retval NULL there is no @p needle in @p haystack.
     151 */
    122152char *pcut_str_find_char(const char *haystack, const char needle);
    123153
  • uspace/lib/pcut/src/list.c

    reeb23f2d r134ac5d  
    3535#include <stdlib.h>
    3636#include "internal.h"
    37 #include <pcut/test.h>
     37#include <pcut/pcut.h>
    3838
    3939
     
    118118}
    119119
     120/** Hide tests that are marked to be skipped.
     121 *
     122 * Go through all tests and those that have PCUT_EXTRA_SKIP mark
     123 * as skipped with PCUT_KIND_SKIP.
     124 *
     125 * @param first Head of the list.
     126 */
     127static void detect_skipped_tests(pcut_item_t *first) {
     128        assert(first != NULL);
     129        if (first->kind == PCUT_KIND_SKIP) {
     130                first = pcut_get_real_next(first);
     131        }
     132        for (pcut_item_t *it = first; it != NULL; it = pcut_get_real_next(it)) {
     133                if (it->kind != PCUT_KIND_TEST) {
     134                        continue;
     135                }
     136                pcut_extra_t *extras = it->test.extras;
     137                while (extras->type != PCUT_EXTRA_LAST) {
     138                        if (extras->type == PCUT_EXTRA_SKIP) {
     139                                it->kind = PCUT_KIND_SKIP;
     140                                break;
     141                        }
     142                        extras++;
     143                }
     144        }
     145}
     146
    120147/** Convert the static single-linked list into a flat double-linked list.
    121148 *
     
    143170        }
    144171
     172        detect_skipped_tests(next);
     173
    145174        set_ids(next);
    146175
  • uspace/lib/pcut/src/os/generic.c

    reeb23f2d r134ac5d  
    7676static char extra_output_buffer[OUTPUT_BUFFER_SIZE];
    7777
    78 /** Prepare for a new test. */
     78/** Prepare for a new test.
     79 *
     80 * @param test Test that is about to start.
     81 */
    7982static void before_test_start(pcut_item_t *test) {
    8083        pcut_report_test_start(test);
  • uspace/lib/pcut/src/os/helenos.c

    reeb23f2d r134ac5d  
    3434#include <stdlib.h>
    3535#include <str.h>
     36#include <str_error.h>
    3637#include <unistd.h>
    3738#include <sys/types.h>
     
    4142#include <task.h>
    4243#include <fcntl.h>
     44#include <fibril_synch.h>
    4345#include "../internal.h"
    4446
     
    6870}
    6971
     72void pcut_str_error(int error, char *buffer, int size) {
     73        const char *str = str_error(error);
     74        if (str == NULL) {
     75                str = "(strerror failure)";
     76        }
     77        str_cpy(buffer, size, str);
     78}
     79
    7080
    7181/* Forking-mode related functions. */
     
    8999static char extra_output_buffer[OUTPUT_BUFFER_SIZE];
    90100
    91 /** Prepare for a new test. */
     101/** Prepare for a new test.
     102 *
     103 * @param test Test that is about to be run.
     104 */
    92105static void before_test_start(pcut_item_t *test) {
    93106        pcut_report_test_start(test);
     
    95108        memset(error_message_buffer, 0, OUTPUT_BUFFER_SIZE);
    96109        memset(extra_output_buffer, 0, OUTPUT_BUFFER_SIZE);
     110}
     111
     112/** Mutex guard for forced_termination_cv. */
     113static fibril_mutex_t forced_termination_mutex
     114        = FIBRIL_MUTEX_INITIALIZER(forced_termination_mutex);
     115
     116/** Condition-variable for checking whether test timed-out. */
     117static fibril_condvar_t forced_termination_cv
     118        = FIBRIL_CONDVAR_INITIALIZER(forced_termination_cv);
     119
     120/** Spawned task id. */
     121static task_id_t test_task_id;
     122
     123/** Flag whether test is still running.
     124 *
     125 * This flag is used when checking whether test timed-out.
     126 */
     127static int test_running;
     128
     129/** Main fibril for checking whether test timed-out.
     130 *
     131 * @param arg Test that is currently running (pcut_item_t *).
     132 * @return EOK Always.
     133 */
     134static int test_timeout_handler_fibril(void *arg) {
     135        pcut_item_t *test = arg;
     136        int timeout_sec = pcut_get_test_timeout(test);
     137        suseconds_t timeout_us = (suseconds_t) timeout_sec * 1000 * 1000;
     138
     139        fibril_mutex_lock(&forced_termination_mutex);
     140        if (!test_running) {
     141                goto leave_no_kill;
     142        }
     143        int rc = fibril_condvar_wait_timeout(&forced_termination_cv,
     144                &forced_termination_mutex, timeout_us);
     145        if (rc == ETIMEOUT) {
     146                task_kill(test_task_id);
     147        }
     148leave_no_kill:
     149        fibril_mutex_unlock(&forced_termination_mutex);
     150        return EOK;
    97151}
    98152
     
    131185        int status = TEST_OUTCOME_PASS;
    132186
    133         task_id_t task_id;
    134         int rc = task_spawnvf(&task_id, self_path, arguments, files);
     187        int rc = task_spawnvf(&test_task_id, self_path, arguments, files);
    135188        if (rc != EOK) {
    136189                status = TEST_OUTCOME_ERROR;
     
    138191        }
    139192
     193        test_running = 1;
     194
     195        fid_t killer_fibril = fibril_create(test_timeout_handler_fibril, test);
     196        if (killer_fibril == 0) {
     197                /* FIXME: somehow announce this problem. */
     198                task_kill(test_task_id);
     199        } else {
     200                fibril_add_ready(killer_fibril);
     201        }
     202
    140203        task_exit_t task_exit;
    141204        int task_retval;
    142         rc = task_wait(task_id, &task_exit, &task_retval);
     205        rc = task_wait(test_task_id, &task_exit, &task_retval);
    143206        if (rc != EOK) {
    144207                status = TEST_OUTCOME_ERROR;
     
    151214        }
    152215
     216        fibril_mutex_lock(&forced_termination_mutex);
     217        test_running = 0;
     218        fibril_condvar_signal(&forced_termination_cv);
     219        fibril_mutex_unlock(&forced_termination_mutex);
     220
    153221        read_all(tempfile, extra_output_buffer, OUTPUT_BUFFER_SIZE);
    154222
  • uspace/lib/pcut/src/os/stdc.c

    reeb23f2d r134ac5d  
    5454        return strchr(haystack, needle);
    5555}
     56
     57void pcut_str_error(int error, char *buffer, int size) {
     58        const char *str = strerror(error);
     59        if (str == NULL) {
     60                str = "(strerror failure)";
     61        }
     62        strncpy(buffer, str, size - 1);
     63        /* Ensure correct termination. */
     64        buffer[size - 1] = 0;
     65}
  • uspace/lib/pcut/src/os/unix.c

    reeb23f2d r134ac5d  
    3232 */
    3333
     34/** We need _POSX_SOURCE because of kill(). */
     35#define _POSIX_SOURCE
    3436#include <stdlib.h>
    3537#include <unistd.h>
    3638#include <sys/types.h>
     39#include <signal.h>
    3740#include <errno.h>
    3841#include <assert.h>
     
    5154static char extra_output_buffer[OUTPUT_BUFFER_SIZE];
    5255
    53 /** Prepare for a new test. */
     56/** Prepare for a new test.
     57 *
     58 * @param test Test that is about to be run.
     59 */
    5460static void before_test_start(pcut_item_t *test) {
    5561        pcut_report_test_start(test);
     
    5763        memset(error_message_buffer, 0, OUTPUT_BUFFER_SIZE);
    5864        memset(extra_output_buffer, 0, OUTPUT_BUFFER_SIZE);
     65}
     66
     67/** PID of the forked process running the actual test. */
     68static pid_t child_pid;
     69
     70/** Signal handler that kills the child.
     71 *
     72 * @param sig Signal number.
     73 */
     74static void kill_child_on_alarm(int sig) {
     75        PCUT_UNUSED(sig);
     76        kill(child_pid, SIGKILL);
    5977}
    6078
     
    124142
    125143        int link_stdout[2], link_stderr[2];
    126         pid_t pid;
    127144
    128145        int rc = pipe(link_stdout);
     
    141158        }
    142159
    143         pid = fork();
    144         if (pid == (pid_t)-1) {
     160        child_pid = fork();
     161        if (child_pid == (pid_t)-1) {
    145162                snprintf(error_message_buffer, OUTPUT_BUFFER_SIZE - 1,
    146163                        "fork() failed: %s.", strerror(rc));
     
    149166        }
    150167
    151         if (pid == 0) {
     168        if (child_pid == 0) {
    152169                /* We are the child. */
    153170                dup2(link_stdout[1], STDOUT_FILENO);
     
    164181        close(link_stderr[1]);
    165182
     183        signal(SIGALRM, kill_child_on_alarm);
     184        alarm(pcut_get_test_timeout(test));
     185
    166186        size_t stderr_size = read_all(link_stderr[0], extra_output_buffer, OUTPUT_BUFFER_SIZE - 1);
    167187        read_all(link_stdout[0], extra_output_buffer, OUTPUT_BUFFER_SIZE - 1 - stderr_size);
     
    169189        int status;
    170190        wait(&status);
     191        alarm(0);
    171192
    172193        rc = convert_wait_status_to_outcome(status);
  • uspace/lib/pcut/src/print.c

    reeb23f2d r134ac5d  
    3232 */
    3333
    34 #include <pcut/test.h>
     34#include <pcut/pcut.h>
    3535#include <stdio.h>
    3636#include <stdlib.h>
  • uspace/lib/pcut/src/report/tap.c

    reeb23f2d r134ac5d  
    4848static int failed_tests_in_suite;
    4949
    50 /** Initialize the tap output. */
     50/** Initialize the TAP output.
     51 *
     52 * @param all_items Start of the list with all items.
     53 */
    5154static void tap_init(pcut_item_t *all_items) {
    5255        int tests_total = pcut_count_tests(all_items);
     
    5659}
    5760
    58 /** Report that a suite was started. */
     61/** Report that a suite was started.
     62 *
     63 * @param suite Suite that just started.
     64 */
    5965static void tap_suite_start(pcut_item_t *suite) {
    6066        tests_in_suite = 0;
     
    6470}
    6571
    66 /** Report that a suite was completed. */
     72/** Report that a suite was completed.
     73 *
     74 * @param suite Suite that just ended.
     75 */
    6776static void tap_suite_done(pcut_item_t *suite) {
    6877        printf("#> Finished suite %s (failed %d of %d).\n",
     
    104113}
    105114
    106 /** Report a completed test. */
     115/** Report a completed test.
     116 *
     117 * @param test Test that just finished.
     118 * @param outcome Outcome of the test.
     119 * @param error_message Buffer with error message.
     120 * @param teardown_error_message Buffer with error message from a tear-down function.
     121 * @param extra_output Extra output from the test (stdout).
     122 */
    107123static void tap_test_done(pcut_item_t *test, int outcome,
    108124                const char *error_message, const char *teardown_error_message,
  • uspace/lib/pcut/src/report/xml.c

    reeb23f2d r134ac5d  
    4848static int failed_tests_in_suite;
    4949
    50 /** Initialize the XML output. */
     50/** Initialize the XML output.
     51 *
     52 * @param all_items Start of the list with all items.
     53 */
    5154static void xml_init(pcut_item_t *all_items) {
    5255        printf("<?xml version=\"1.0\"?>\n");
     
    5861}
    5962
    60 /** Report that a suite was started. */
     63/** Report that a suite was started.
     64 *
     65 * @param suite Suite that just started.
     66 */
    6167static void xml_suite_start(pcut_item_t *suite) {
    6268        tests_in_suite = 0;
     
    6672}
    6773
    68 /** Report that a suite was completed. */
     74/** Report that a suite was completed.
     75 *
     76 * @param suite Suite that just ended.
     77 */
    6978static void xml_suite_done(pcut_item_t *suite) {
    7079        printf("\t</suite><!-- %s: %d / %d -->\n", suite->suite.name,
     
    111120}
    112121
    113 /** Report a completed test. */
     122/** Report a completed test.
     123 *
     124 * @param test Test that just finished.
     125 * @param outcome Outcome of the test.
     126 * @param error_message Buffer with error message.
     127 * @param teardown_error_message Buffer with error message from a tear-down function.
     128 * @param extra_output Extra output from the test (stdout).
     129 */
    114130static void xml_test_done(pcut_item_t *test, int outcome,
    115131                const char *error_message, const char *teardown_error_message,
  • uspace/lib/pcut/src/run.c

    reeb23f2d r134ac5d  
    267267}
    268268
     269/** Tells time-out length for a given test.
     270 *
     271 * @param test Test for which the time-out is questioned.
     272 * @return Timeout in seconds.
     273 */
     274int pcut_get_test_timeout(pcut_item_t *test) {
     275        PCUT_UNUSED(test);
     276
     277        int timeout = PCUT_DEFAULT_TEST_TIMEOUT;
     278
     279        pcut_extra_t *extras = test->test.extras;
     280        while (extras->type != PCUT_EXTRA_LAST) {
     281                if (extras->type == PCUT_EXTRA_TIMEOUT) {
     282                        timeout = extras->timeout;
     283                }
     284                extras++;
     285        }
     286
     287        return timeout;
     288}
  • uspace/lib/pcut/tests/alloc.c

    reeb23f2d r134ac5d  
    2727 */
    2828
    29 #include <pcut/test.h>
     29#include <pcut/pcut.h>
    3030#include <stdlib.h>
    3131#include <stdio.h>
  • uspace/lib/pcut/tests/asserts.c

    reeb23f2d r134ac5d  
    2727 */
    2828
    29 #include <pcut/test.h>
     29#include <pcut/pcut.h>
    3030#include "tested.h"
    3131
     
    4747}
    4848
     49PCUT_TEST(str_equals_or_null_base) {
     50        PCUT_ASSERT_STR_EQUALS_OR_NULL("xyz", "xyz");
     51}
     52
     53PCUT_TEST(str_equals_or_null_different) {
     54        PCUT_ASSERT_STR_EQUALS_OR_NULL("abc", "xyz");
     55}
     56
     57PCUT_TEST(str_equals_or_null_one_null) {
     58        PCUT_ASSERT_STR_EQUALS_OR_NULL(NULL, "xyz");
     59}
     60
     61PCUT_TEST(str_equals_or_null_both) {
     62        PCUT_ASSERT_STR_EQUALS_OR_NULL(NULL, NULL);
     63}
     64
     65PCUT_TEST(assert_true) {
     66        PCUT_ASSERT_TRUE(42);
     67        PCUT_ASSERT_TRUE(0);
     68}
     69
     70PCUT_TEST(assert_false) {
     71        PCUT_ASSERT_FALSE(0);
     72        PCUT_ASSERT_FALSE(42);
     73}
     74
    4975PCUT_MAIN()
  • uspace/lib/pcut/tests/asserts.expected

    reeb23f2d r134ac5d  
    1 1..3
     11..9
    22#> Starting suite Default.
    33not ok 1 int_equals failed
     
    77not ok 3 str_equals failed
    88# error: asserts.c:46: Expected <abc> but got <xyz> ("abc" != "xyz")
    9 #> Finished suite Default (failed 3 of 3).
     9ok 4 str_equals_or_null_base
     10not ok 5 str_equals_or_null_different failed
     11# error: asserts.c:54: Expected <abc> but got <xyz> ("abc" != "xyz")
     12not ok 6 str_equals_or_null_one_null failed
     13# error: asserts.c:58: Expected <NULL> but got <xyz> (NULL != "xyz")
     14ok 7 str_equals_or_null_both
     15not ok 8 assert_true failed
     16# error: asserts.c:67: Expected true but got <0>
     17not ok 9 assert_false failed
     18# error: asserts.c:72: Expected false but got <42>
     19#> Finished suite Default (failed 7 of 9).
  • uspace/lib/pcut/tests/manytests.c

    reeb23f2d r134ac5d  
    2727 */
    2828
    29 #include <pcut/test.h>
     29#include <pcut/pcut.h>
    3030
    3131/*
  • uspace/lib/pcut/tests/null.c

    reeb23f2d r134ac5d  
    2727 */
    2828
    29 #include <pcut/test.h>
     29#include <pcut/pcut.h>
    3030#include "tested.h"
    3131
  • uspace/lib/pcut/tests/nullteardown.c

    reeb23f2d r134ac5d  
    2828
    2929#include <stdio.h>
    30 #include <pcut/test.h>
     30#include <pcut/pcut.h>
    3131#include "tested.h"
    3232
  • uspace/lib/pcut/tests/printing.c

    reeb23f2d r134ac5d  
    2727 */
    2828
    29 #include <pcut/test.h>
     29#include <pcut/pcut.h>
    3030#include "tested.h"
    3131#include <stdio.h>
  • uspace/lib/pcut/tests/simple.c

    reeb23f2d r134ac5d  
    2727 */
    2828
    29 #include <pcut/test.h>
     29#include <pcut/pcut.h>
    3030#include "tested.h"
    3131
  • uspace/lib/pcut/tests/suite1.c

    reeb23f2d r134ac5d  
    2727 */
    2828
    29 #include <pcut/test.h>
     29#include <pcut/pcut.h>
    3030#include "tested.h"
    3131
  • uspace/lib/pcut/tests/suite2.c

    reeb23f2d r134ac5d  
    2727 */
    2828
    29 #include <pcut/test.h>
     29#include <pcut/pcut.h>
    3030#include "tested.h"
    3131
  • uspace/lib/pcut/tests/suite_all.c

    reeb23f2d r134ac5d  
    2727 */
    2828
    29 #include <pcut/test.h>
     29#include <pcut/pcut.h>
    3030
    3131PCUT_INIT
  • uspace/lib/pcut/tests/suites.c

    reeb23f2d r134ac5d  
    2727 */
    2828
    29 #include <pcut/test.h>
     29#include <pcut/pcut.h>
    3030#include "tested.h"
    3131
  • uspace/lib/pcut/tests/teardown.c

    reeb23f2d r134ac5d  
    2828
    2929#include <stdio.h>
    30 #include <pcut/test.h>
     30#include <pcut/pcut.h>
    3131#include "tested.h"
    3232
  • uspace/lib/pcut/tests/tests.mak

    reeb23f2d r134ac5d  
    2727#
    2828
    29 TEST_DEPS = $(TEST_BASE)tested.o $(PCUT_LIB)
     29TEST_DEPS = $(TEST_BASE)tested.o
    3030
    3131TEST_APPS = \
    3232        $(TEST_BASE)alloc.$(EXE_EXT) \
    3333        $(TEST_BASE)asserts.$(EXE_EXT) \
     34        $(TEST_BASE)errno.$(EXE_EXT) \
    3435        $(TEST_BASE)manytests.$(EXE_EXT) \
    3536        $(TEST_BASE)multisuite.$(EXE_EXT) \
     
    3839        $(TEST_BASE)printing.$(EXE_EXT) \
    3940        $(TEST_BASE)simple.$(EXE_EXT) \
     41        $(TEST_BASE)skip.$(EXE_EXT) \
    4042        $(TEST_BASE)suites.$(EXE_EXT) \
    41         $(TEST_BASE)teardown.$(EXE_EXT)
     43        $(TEST_BASE)teardown.$(EXE_EXT) \
     44        $(TEST_BASE)timeout.$(EXE_EXT)
    4245
    4346check-build: $(TEST_APPS)
     
    4649
    4750check-clean:
    48         rm -f $(TEST_BASE)*.o $(TEST_BASE)*.$(EXE_EXT) $(TEST_BASE)*.got
     51        rm -f $(TEST_BASE)*.o $(TEST_BASE)*.pcut.c $(TEST_BASE)*.$(EXE_EXT) $(TEST_BASE)*.got
    4952
    5053$(TEST_BASE)%.$(EXE_EXT): $(TEST_DEPS)
    51         $(CC) -o $@ $^ $(TEST_LDFLAGS)
     54        $(LD) -o $@ $^ $(TEST_LDFLAGS)
    5255
    53 $(TEST_BASE)alloc.$(EXE_EXT): $(TEST_BASE)alloc.o
    54 $(TEST_BASE)asserts.$(EXE_EXT): $(TEST_BASE)asserts.o
    55 $(TEST_BASE)manytests.$(EXE_EXT): $(TEST_BASE)manytests.o
    56 $(TEST_BASE)multisuite.$(EXE_EXT): $(TEST_BASE)suite_all.o $(TEST_BASE)suite1.o $(TEST_BASE)suite2.o
    57 $(TEST_BASE)null.$(EXE_EXT): $(TEST_BASE)null.o
    58 $(TEST_BASE)nullteardown.$(EXE_EXT): $(TEST_BASE)nullteardown.o
    59 $(TEST_BASE)printing.$(EXE_EXT): $(TEST_BASE)printing.o
    60 $(TEST_BASE)simple.$(EXE_EXT): $(TEST_BASE)simple.o
    61 $(TEST_BASE)suites.$(EXE_EXT): $(TEST_BASE)suites.o
    62 $(TEST_BASE)teardown.$(EXE_EXT): $(TEST_BASE)teardown.o
     56$(TEST_BASE)alloc.$(EXE_EXT): $(TEST_BASE)alloc.o $(PCUT_LIB)
     57$(TEST_BASE)asserts.$(EXE_EXT): $(TEST_BASE)asserts.o $(PCUT_LIB)
     58$(TEST_BASE)errno.$(EXE_EXT): $(TEST_BASE)errno.o $(PCUT_LIB)
     59$(TEST_BASE)manytests.$(EXE_EXT): $(TEST_BASE)manytests.o $(PCUT_LIB)
     60$(TEST_BASE)multisuite.$(EXE_EXT): $(TEST_BASE)suite_all.o $(TEST_BASE)suite1.o $(TEST_BASE)suite2.o $(PCUT_LIB)
     61$(TEST_BASE)null.$(EXE_EXT): $(TEST_BASE)null.o $(PCUT_LIB)
     62$(TEST_BASE)nullteardown.$(EXE_EXT): $(TEST_BASE)nullteardown.o $(PCUT_LIB)
     63$(TEST_BASE)printing.$(EXE_EXT): $(TEST_BASE)printing.o $(PCUT_LIB)
     64$(TEST_BASE)simple.$(EXE_EXT): $(TEST_BASE)simple.o $(PCUT_LIB)
     65$(TEST_BASE)skip.$(EXE_EXT): $(TEST_BASE)skip.o $(PCUT_LIB)
     66$(TEST_BASE)suites.$(EXE_EXT): $(TEST_BASE)suites.o $(PCUT_LIB)
     67$(TEST_BASE)teardown.$(EXE_EXT): $(TEST_BASE)teardown.o $(PCUT_LIB)
     68$(TEST_BASE)timeout.$(EXE_EXT): $(TEST_BASE)timeout.o $(PCUT_LIB)
    6369
     70
     71ifeq ($(NEEDS_PREPROC),y)
     72$(TEST_BASE)%.o: $(TEST_BASE)%.pcut.c
     73        $(CC) -c -o $@ $(TEST_CFLAGS) $<
     74
     75$(TEST_BASE)%.pcut.c: $(TEST_BASE)%.c $(PCUT_PREPROC)
     76        $(CC) -E $(TEST_CFLAGS) $< | $(PCUT_PREPROC) >$@
     77else
    6478$(TEST_BASE)%.o: $(TEST_BASE)%.c
    6579        $(CC) -c -o $@ $(TEST_CFLAGS) $<
     80endif
  • uspace/lib/pcut/unix.mak

    reeb23f2d r134ac5d  
    3030OBJ_EXT = o
    3131PCUT_LIB = libpcut.a
     32PCUT_PREPROC = ./pcut.bin
    3233
    3334# Installation paths
     
    3940
    4041PCUT_OBJECTS := $(addsuffix .o,$(basename $(PCUT_SOURCES)))
     42PCUT_PREPROC_OBJECTS := $(addsuffix .o,$(basename $(PCUT_PREPROC_SOURCES)))
    4143
    4244# Take care of dependencies
     
    5355EXE_EXT = run
    5456TEST_CFLAGS = $(PCUT_CFLAGS)
    55 TEST_LDFLAGS = -L. -lpcut
     57TEST_LDFLAGS =
    5658-include tests/tests.mak
    5759TEST_APPS_BASENAMES := $(basename $(TEST_APPS))
     
    7577#
    7678platform-clean:
    77         rm -f libpcut.a $(DEPEND)
     79        rm -f $(DEPEND) $(PCUT_LIB) $(PCUT_PREPROC)
    7880
    7981#
     
    8385        $(AR) rc $@ $(PCUT_OBJECTS)
    8486        $(RANLIB) $@
     87
     88$(PCUT_PREPROC): $(PCUT_PREPROC_OBJECTS)
     89        $(LD) $(LDFLAGS) -o $@ $(PCUT_PREPROC_OBJECTS)
    8590
    8691%.o: $(DEPEND)
  • uspace/lib/posix/test/main.c

    reeb23f2d r134ac5d  
    2727 */
    2828
    29 #include <pcut/test.h>
     29#include <pcut/pcut.h>
    3030
    3131PCUT_INIT
  • uspace/lib/posix/test/scanf.c

    reeb23f2d r134ac5d  
    3333#include "posix/stdio.h"
    3434
    35 #include <pcut/test.h>
     35#include <pcut/pcut.h>
    3636
    3737
Note: See TracChangeset for help on using the changeset viewer.