Changeset 4b54bd9 in mainline for uspace/lib/pcut/src


Ignore:
Timestamp:
2018-09-12T13:23:03Z (7 years ago)
Author:
Vojtech Horky <vojtech.horky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3da0ee4
Parents:
275530a4
Message:

Update PCUT to latest revision

Location:
uspace/lib/pcut/src
Files:
1 added
15 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/pcut/src/assert.c

    r275530a4 r4b54bd9  
    4343
    4444#include "internal.h"
     45
     46#pragma warning(push, 0)
    4547#include <setjmp.h>
    4648#include <stdarg.h>
    4749#include <stdio.h>
     50#pragma warning(pop)
     51
    4852
    4953/** Maximum length of failed-assert message. */
     
    5963static int message_buffer_index = 0;
    6064
    61 void pcut_failed_assertion_fmt(const char *filename, int line, const char *fmt, ...)
    62 {
     65void pcut_failed_assertion_fmt(const char *filename, int line, const char *fmt, ...) {
    6366        va_list args;
    6467        char *current_buffer = message_buffer[message_buffer_index];
     
    6669        message_buffer_index = (message_buffer_index + 1) % MESSAGE_BUFFER_COUNT;
    6770
    68         snprintf(current_buffer, MAX_MESSAGE_LENGTH, "%s:%d: ", filename, line);
     71        pcut_snprintf(current_buffer, MAX_MESSAGE_LENGTH, "%s:%d: ", filename, line);
    6972        offset = pcut_str_size(current_buffer);
    7073
  • uspace/lib/pcut/src/internal.h

    r275530a4 r4b54bd9  
    3535
    3636#include <pcut/pcut.h>
     37
     38#pragma warning(push, 0)
    3739#include <stdlib.h>
     40#pragma warning(pop)
    3841
    3942
     
    4851 */
    4952#ifdef PCUT_DEBUG_BUILD
     53#pragma warning(push, 0)
    5054#include <stdio.h>
     55#pragma warning(pop)
    5156#define PCUT_DEBUG_INTERNAL(msg, ...) \
    5257        fprintf(stderr, "[PCUT %s:%d]: " msg "%s", __FILE__, __LINE__, __VA_ARGS__)
     
    7883 */
    7984#define PCUT_RUN_MODE_SINGLE 2
    80 
    81 /*
    82  * Use sprintf_s in Windows but only with Microsoft compiler.
    83  * Namely, let MinGW use snprintf.
    84  */
    85 #if (defined(__WIN64) || defined(__WIN32) || defined(_WIN32)) && defined(_MSC_VER)
    86 #define snprintf sprintf_s
    87 #endif
    8885
    8986extern int pcut_run_mode;
     
    125122        /** Test completed. */
    126123        void (*test_done)(pcut_item_t *, int, const char *, const char *,
    127             const char *);
     124                const char *);
    128125};
    129126
     
    135132void pcut_report_test_start(pcut_item_t *test);
    136133void pcut_report_test_done(pcut_item_t *test, int outcome,
    137     const char *error_message, const char *teardown_error_message,
    138     const char *extra_output);
     134                const char *error_message, const char *teardown_error_message,
     135                const char *extra_output);
    139136void pcut_report_test_done_unparsed(pcut_item_t *test, int outcome,
    140     const char *unparsed_output, size_t unparsed_output_size);
     137                const char *unparsed_output, size_t unparsed_output_size);
    141138void pcut_report_done(void);
    142139
     
    187184char *pcut_str_find_char(const char *haystack, const char needle);
    188185
     186/** Format string to a buffer.
     187 *
     188 */
     189int pcut_snprintf(char *dest, size_t size, const char *format, ...);
    189190
    190191#endif
  • uspace/lib/pcut/src/list.c

    r275530a4 r4b54bd9  
    3232 */
    3333
     34#pragma warning(push, 0)
    3435#include <assert.h>
    3536#include <stdlib.h>
     37#pragma warning(pop)
     38
    3639#include "internal.h"
    3740#include <pcut/pcut.h>
     
    4346 * @return First item with actual content or NULL on end of list.
    4447 */
    45 pcut_item_t *pcut_get_real_next(pcut_item_t *item)
    46 {
     48pcut_item_t *pcut_get_real_next(pcut_item_t *item) {
    4749        if (item == NULL) {
    4850                return NULL;
     
    6567 * @return First item with actual content or NULL on end of list.
    6668 */
    67 pcut_item_t *pcut_get_real(pcut_item_t *item)
    68 {
     69pcut_item_t *pcut_get_real(pcut_item_t *item) {
    6970        if (item == NULL) {
    7071                return NULL;
     
    8384 * @param nested Head of the nested list.
    8485 */
    85 static void inline_nested_lists(pcut_item_t *nested)
    86 {
     86static void inline_nested_lists(pcut_item_t *nested) {
    8787        pcut_item_t *first;
    8888
     
    111111 * @param first List head.
    112112 */
    113 static void set_ids(pcut_item_t *first)
    114 {
     113static void set_ids(pcut_item_t *first) {
    115114        int id = 1;
    116115        pcut_item_t *it;
     
    135134 * @param first Head of the list.
    136135 */
    137 static void detect_skipped_tests(pcut_item_t *first)
    138 {
     136static void detect_skipped_tests(pcut_item_t *first) {
    139137        pcut_item_t *it;
    140138
     
    172170 * @return Head of the fixed list.
    173171 */
    174 pcut_item_t *pcut_fix_list_get_real_head(pcut_item_t *last)
    175 {
     172pcut_item_t *pcut_fix_list_get_real_head(pcut_item_t *last) {
    176173        pcut_item_t *next, *it;
    177174
     
    201198 * @return Number of tests.
    202199 */
    203 int pcut_count_tests(pcut_item_t *it)
    204 {
     200int pcut_count_tests(pcut_item_t *it) {
    205201        int count = 0;
    206202        while (it != NULL) {
  • uspace/lib/pcut/src/main.c

    r275530a4 r4b54bd9  
    3434#include "internal.h"
    3535#include "report/report.h"
     36
     37#pragma warning(push, 0)
    3638#include <assert.h>
    3739#include <stdlib.h>
    3840#include <stdio.h>
     41#pragma warning(pop)
     42
    3943
    4044/** Current running mode. */
     
    5761 * @return Whether @p arg is @p opt followed by a number.
    5862 */
    59 int pcut_is_arg_with_number(const char *arg, const char *opt, int *value)
    60 {
     63int pcut_is_arg_with_number(const char *arg, const char *opt, int *value) {
    6164        int opt_len = pcut_str_size(opt);
    62         if (!pcut_str_start_equals(arg, opt, opt_len)) {
     65        if (! pcut_str_start_equals(arg, opt, opt_len)) {
    6366                return 0;
    6467        }
     
    7578 * @retval NULL No item with such id exists in the list.
    7679 */
    77 static pcut_item_t *pcut_find_by_id(pcut_item_t *first, int id)
    78 {
     80static pcut_item_t *pcut_find_by_id(pcut_item_t *first, int id) {
    7981        pcut_item_t *it = pcut_get_real(first);
    8082        while (it != NULL) {
     
    9496 * @return Error code.
    9597 */
    96 static int run_suite(pcut_item_t *suite, pcut_item_t **last, const char *prog_path)
    97 {
     98static int run_suite(pcut_item_t *suite, pcut_item_t **last, const char *prog_path) {
    9899        int is_first_test = 1;
    99100        int total_count = 0;
     
    159160 * @param first First item of the list.
    160161 */
    161 static void set_setup_teardown_callbacks(pcut_item_t *first)
    162 {
     162static void set_setup_teardown_callbacks(pcut_item_t *first) {
    163163        pcut_item_t *active_suite = NULL;
    164164        pcut_item_t *it;
     
    192192 * @return Program exit code.
    193193 */
    194 int pcut_main(pcut_item_t *last, int argc, char *argv[])
    195 {
     194int pcut_main(pcut_item_t *last, int argc, char *argv[]) {
    196195        pcut_item_t *items = pcut_fix_list_get_real_head(last);
    197196        pcut_item_t *it;
  • uspace/lib/pcut/src/os/generic.c

    r275530a4 r4b54bd9  
    3131 * Platform-dependent test execution function when system() is available.
    3232 */
    33 
     33#pragma warning(push, 0)
    3434#include <stdlib.h>
    3535#include <stdio.h>
     
    3838#include <assert.h>
    3939#include <string.h>
     40#pragma warning(pop)
     41
    4042#include "../internal.h"
    4143
     
    5557
    5658#define FORMAT_COMMAND(buffer, buffer_size, self_path, test_id, temp_file) \
    57         snprintf(buffer, buffer_size, "\"\"%s\" -t%d >%s\"", self_path, test_id, temp_file)
     59        pcut_snprintf(buffer, buffer_size, "\"\"%s\" -t%d >%s\"", self_path, test_id, temp_file)
    5860#define FORMAT_TEMP_FILENAME(buffer, buffer_size) \
    59         snprintf(buffer, buffer_size, "pcut_%d.tmp", _getpid())
     61        pcut_snprintf(buffer, buffer_size, "pcut_%d.tmp", _getpid())
    6062
    6163#elif defined(__unix)
     
    6365
    6466#define FORMAT_COMMAND(buffer, buffer_size, self_path, test_id, temp_file) \
    65         snprintf(buffer, buffer_size, "%s -t%d &>%s", self_path, test_id, temp_file)
     67        pcut_snprintf(buffer, buffer_size, "%s -t%d &>%s", self_path, test_id, temp_file)
    6668#define FORMAT_TEMP_FILENAME(buffer, buffer_size) \
    67         snprintf(buffer, buffer_size, "pcut_%d.tmp", getpid())
     69        pcut_snprintf(buffer, buffer_size, "pcut_%d.tmp", getpid())
    6870
    6971#else
     
    8183 * @param test Test that is about to start.
    8284 */
    83 static void before_test_start(pcut_item_t *test)
    84 {
     85static void before_test_start(pcut_item_t *test) {
    8586        pcut_report_test_start(test);
    8687
     
    9495 * @return Test outcome code.
    9596 */
    96 static int convert_wait_status_to_outcome(int status)
    97 {
     97static int convert_wait_status_to_outcome(int status) {
    9898        if (status < 0) {
    9999                return PCUT_OUTCOME_INTERNAL_ERROR;
     
    110110 * @param test Test to be run.
    111111 */
    112 int pcut_run_test_forking(const char *self_path, pcut_item_t *test)
    113 {
     112int pcut_run_test_forking(const char *self_path, pcut_item_t *test) {
    114113        int rc, outcome;
    115114        FILE *tempfile;
     
    121120        FORMAT_TEMP_FILENAME(tempfile_name, PCUT_TEMP_FILENAME_BUFFER_SIZE - 1);
    122121        FORMAT_COMMAND(command, PCUT_COMMAND_LINE_BUFFER_SIZE - 1,
    123             self_path, (test)->id, tempfile_name);
    124 
     122                self_path, (test)->id, tempfile_name);
     123       
    125124        PCUT_DEBUG("Will execute <%s> (temp file <%s>) with system().",
    126             command, tempfile_name);
     125                command, tempfile_name);
    127126
    128127        rc = system(command);
     
    147146}
    148147
    149 void pcut_hook_before_test(pcut_item_t *test)
    150 {
     148void pcut_hook_before_test(pcut_item_t *test) {
    151149        PCUT_UNUSED(test);
    152150
  • uspace/lib/pcut/src/os/helenos.c

    r275530a4 r4b54bd9  
    4646/* String functions. */
    4747
    48 int pcut_str_equals(const char *a, const char *b)
    49 {
     48int pcut_str_equals(const char *a, const char *b) {
    5049        return str_cmp(a, b) == 0;
    5150}
    5251
    5352
    54 int pcut_str_start_equals(const char *a, const char *b, int len)
    55 {
     53int pcut_str_start_equals(const char *a, const char *b, int len) {
    5654        return str_lcmp(a, b, len) == 0;
    5755}
    5856
    59 int pcut_str_size(const char *s)
    60 {
     57int pcut_str_size(const char *s) {
    6158        return str_size(s);
    6259}
    6360
    64 int pcut_str_to_int(const char *s)
    65 {
     61int pcut_str_to_int(const char *s) {
    6662        int result = strtol(s, NULL, 10);
    6763        return result;
    6864}
    6965
    70 char *pcut_str_find_char(const char *haystack, const char needle)
    71 {
     66char *pcut_str_find_char(const char *haystack, const char needle) {
    7267        return str_chr(haystack, needle);
    7368}
    7469
    75 void pcut_str_error(errno_t error, char *buffer, int size)
    76 {
     70void pcut_str_error(int error, char *buffer, int size) {
    7771        const char *str = str_error(error);
    7872        if (str == NULL) {
     
    107101 * @param test Test that is about to be run.
    108102 */
    109 static void before_test_start(pcut_item_t *test)
    110 {
     103static void before_test_start(pcut_item_t *test) {
    111104        pcut_report_test_start(test);
    112105
     
    116109
    117110/** Mutex guard for forced_termination_cv. */
    118 static fibril_mutex_t forced_termination_mutex =
    119     FIBRIL_MUTEX_INITIALIZER(forced_termination_mutex);
     111static fibril_mutex_t forced_termination_mutex
     112        = FIBRIL_MUTEX_INITIALIZER(forced_termination_mutex);
    120113
    121114/** Condition-variable for checking whether test timed-out. */
    122 static fibril_condvar_t forced_termination_cv =
    123     FIBRIL_CONDVAR_INITIALIZER(forced_termination_cv);
     115static fibril_condvar_t forced_termination_cv
     116        = FIBRIL_CONDVAR_INITIALIZER(forced_termination_cv);
    124117
    125118/** Spawned task id. */
     
    137130 * @return EOK Always.
    138131 */
    139 static errno_t test_timeout_handler_fibril(void *arg)
    140 {
     132static int test_timeout_handler_fibril(void *arg) {
    141133        pcut_item_t *test = arg;
    142134        int timeout_sec = pcut_get_test_timeout(test);
     
    148140        }
    149141        errno_t rc = fibril_condvar_wait_timeout(&forced_termination_cv,
    150             &forced_termination_mutex, timeout_us);
     142                &forced_termination_mutex, timeout_us);
    151143        if (rc == ETIMEOUT) {
    152144                task_kill(test_task_id);
     
    162154 * @param test Test to be run.
    163155 */
    164 int pcut_run_test_forking(const char *self_path, pcut_item_t *test)
    165 {
     156int pcut_run_test_forking(const char *self_path, pcut_item_t *test) {
    166157        before_test_start(test);
    167158
     
    235226}
    236227
    237 void pcut_hook_before_test(pcut_item_t *test)
    238 {
     228void pcut_hook_before_test(pcut_item_t *test) {
    239229        PCUT_UNUSED(test);
    240230
  • uspace/lib/pcut/src/os/stdc.c

    r275530a4 r4b54bd9  
    3232 */
    3333
     34#pragma warning(push, 0)
    3435#include <string.h>
     36#pragma warning(pop)
     37
    3538#include "../internal.h"
    3639
    37 int pcut_str_equals(const char *a, const char *b)
    38 {
     40int pcut_str_equals(const char *a, const char *b) {
    3941        return strcmp(a, b) == 0;
    4042}
    4143
    42 int pcut_str_start_equals(const char *a, const char *b, int len)
    43 {
     44int pcut_str_start_equals(const char *a, const char *b, int len) {
    4445        return strncmp(a, b, len) == 0;
    4546}
    4647
    47 int pcut_str_size(const char *s)
    48 {
     48int pcut_str_size(const char *s) {
    4949        return strlen(s);
    5050}
    5151
    52 int pcut_str_to_int(const char *s)
    53 {
     52int pcut_str_to_int(const char *s) {
    5453        return atoi(s);
    5554}
    5655
    57 char *pcut_str_find_char(const char *haystack, const char needle)
    58 {
     56char *pcut_str_find_char(const char *haystack, const char needle) {
    5957        return strchr(haystack, needle);
    6058}
    6159
    62 void pcut_str_error(int error, char *buffer, int size)
    63 {
     60void pcut_str_error(int error, char *buffer, int size) {
    6461        const char *str = strerror(error);
    6562        if (str == NULL) {
  • uspace/lib/pcut/src/os/unix.c

    r275530a4 r4b54bd9  
    6464 * @param test Test that is about to be run.
    6565 */
    66 static void before_test_start(pcut_item_t *test)
    67 {
     66static void before_test_start(pcut_item_t *test) {
    6867        pcut_report_test_start(test);
    6968
     
    7978 * @param sig Signal number.
    8079 */
    81 static void kill_child_on_alarm(int sig)
    82 {
     80static void kill_child_on_alarm(int sig) {
    8381        PCUT_UNUSED(sig);
    8482        kill(child_pid, SIGKILL);
     
    9694 * @return Number of actually read bytes.
    9795 */
    98 static size_t read_all(int fd, char *buffer, size_t buffer_size)
    99 {
     96static size_t read_all(int fd, char *buffer, size_t buffer_size) {
    10097        ssize_t actually_read;
    10198        char *buffer_start = buffer;
     
    124121 * @return Test outcome code.
    125122 */
    126 static int convert_wait_status_to_outcome(int status)
    127 {
     123static int convert_wait_status_to_outcome(int status) {
    128124        if (WIFEXITED(status)) {
    129125                if (WEXITSTATUS(status) != 0) {
     
    146142 * @param test Test to be run.
    147143 */
    148 int pcut_run_test_forking(const char *self_path, pcut_item_t *test)
    149 {
     144int pcut_run_test_forking(const char *self_path, pcut_item_t *test) {
    150145        int link_stdout[2], link_stderr[2];
    151146        int rc, status, outcome;
     
    159154        rc = pipe(link_stdout);
    160155        if (rc == -1) {
    161                 snprintf(error_message_buffer, OUTPUT_BUFFER_SIZE - 1,
    162                     "pipe() failed: %s.", strerror(rc));
     156                pcut_snprintf(error_message_buffer, OUTPUT_BUFFER_SIZE - 1,
     157                                "pipe() failed: %s.", strerror(rc));
    163158                pcut_report_test_done(test, PCUT_OUTCOME_INTERNAL_ERROR, error_message_buffer, NULL, NULL);
    164159                return PCUT_OUTCOME_INTERNAL_ERROR;
     
    166161        rc = pipe(link_stderr);
    167162        if (rc == -1) {
    168                 snprintf(error_message_buffer, OUTPUT_BUFFER_SIZE - 1,
    169                     "pipe() failed: %s.", strerror(rc));
     163                pcut_snprintf(error_message_buffer, OUTPUT_BUFFER_SIZE - 1,
     164                                "pipe() failed: %s.", strerror(rc));
    170165                pcut_report_test_done(test, PCUT_OUTCOME_INTERNAL_ERROR, error_message_buffer, NULL, NULL);
    171166                return PCUT_OUTCOME_INTERNAL_ERROR;
     
    174169        child_pid = fork();
    175170        if (child_pid == (pid_t)-1) {
    176                 snprintf(error_message_buffer, OUTPUT_BUFFER_SIZE - 1,
    177                     "fork() failed: %s.", strerror(rc));
     171                pcut_snprintf(error_message_buffer, OUTPUT_BUFFER_SIZE - 1,
     172                        "fork() failed: %s.", strerror(rc));
    178173                outcome = PCUT_OUTCOME_INTERNAL_ERROR;
    179174                goto leave_close_pipes;
     
    220215}
    221216
    222 void pcut_hook_before_test(pcut_item_t *test)
    223 {
     217void pcut_hook_before_test(pcut_item_t *test) {
    224218        PCUT_UNUSED(test);
    225219
  • uspace/lib/pcut/src/os/windows.c

    r275530a4 r4b54bd9  
    3939#include "../internal.h"
    4040
     41#pragma warning(push, 0)
    4142#include <windows.h>
    4243#include <tchar.h>
    4344#include <stdio.h>
    4445#include <strsafe.h>
     46#pragma warning(pop)
     47
    4548
    4649
     
    6164 * @param test Test that is about to be run.
    6265 */
    63 static void before_test_start(pcut_item_t *test)
    64 {
     66static void before_test_start(pcut_item_t *test) {
    6567        pcut_report_test_start(test);
    6668
     
    7476 * @param failed_function_name Name of the failed function.
    7577 */
    76 static void report_func_fail(pcut_item_t *test, const char *failed_function_name)
    77 {
     78static void report_func_fail(pcut_item_t *test, const char *failed_function_name) {
    7879        /* TODO: get error description. */
    79         sprintf_s(error_message_buffer, OUTPUT_BUFFER_SIZE - 1,
    80             "%s failed: %s.", failed_function_name, "unknown reason");
    81         pcut_report_test_done(test, TEST_OUTCOME_ERROR, error_message_buffer, NULL, NULL);
     80        pcut_snprintf(error_message_buffer, OUTPUT_BUFFER_SIZE - 1,
     81                "%s failed: %s.", failed_function_name, "unknown reason");
     82        pcut_report_test_done(test, PCUT_OUTCOME_INTERNAL_ERROR, error_message_buffer, NULL, NULL);
    8283}
    8384
     
    9394 * @return Number of actually read bytes.
    9495 */
    95 static size_t read_all(HANDLE fd, char *buffer, size_t buffer_size)
    96 {
     96static size_t read_all(HANDLE fd, char *buffer, size_t buffer_size) {
    9797        DWORD actually_read;
    9898        char *buffer_start = buffer;
     
    128128};
    129129
    130 static DWORD WINAPI read_test_output_on_background(LPVOID test_output_data_ptr)
    131 {
     130static DWORD WINAPI read_test_output_on_background(LPVOID test_output_data_ptr) {
    132131        size_t stderr_size = 0;
    133132        struct test_output_data *test_output_data = (struct test_output_data *) test_output_data_ptr;
    134133
    135134        stderr_size = read_all(test_output_data->pipe_stderr,
    136             test_output_data->output_buffer,
    137             test_output_data->output_buffer_size - 1);
     135                test_output_data->output_buffer,
     136                test_output_data->output_buffer_size - 1);
    138137        read_all(test_output_data->pipe_stdout,
    139             test_output_data->output_buffer,
    140             test_output_data->output_buffer_size - 1 - stderr_size);
     138                test_output_data->output_buffer,
     139                test_output_data->output_buffer_size - 1 - stderr_size);
    141140
    142141        return 0;
     
    148147 * @param test Test to be run.
    149148 */
    150 int pcut_run_test_forking(const char *self_path, pcut_item_t *test)
    151 {
     149int pcut_run_test_forking(const char *self_path, pcut_item_t *test) {
    152150        /* TODO: clean-up if something goes wrong "in the middle" */
    153151        BOOL okay = FALSE;
     
    220218
    221219        /* Format the command line. */
    222         sprintf_s(command, PCUT_COMMAND_LINE_BUFFER_SIZE - 1,
    223             "\"%s\" -t%d", self_path, test->id);
     220        pcut_snprintf(command, PCUT_COMMAND_LINE_BUFFER_SIZE - 1,
     221                "\"%s\" -t%d", self_path, test->id);
    224222
    225223        /* Run the process. */
    226224        okay = CreateProcess(NULL, command, NULL, NULL, TRUE, 0, NULL, NULL,
    227             &start_info, &process_info);
     225                &start_info, &process_info);
    228226
    229227        if (!okay) {
     
    267265
    268266        test_output_thread_reader = CreateThread(NULL, 0,
    269             read_test_output_on_background, &test_output_data,
    270             0, NULL);
     267                read_test_output_on_background, &test_output_data,
     268                0, NULL);
    271269
    272270        if (test_output_thread_reader == NULL) {
     
    286284                if (!okay) {
    287285                        report_func_fail(test, "TerminateProcess(/* PROCESS_INFORMATION.hProcess */)");
    288                         return PCUT_ERROR_INTERNAL_FAILURE;
     286                        return PCUT_OUTCOME_INTERNAL_ERROR;
    289287                }
    290288                rc = WaitForSingleObject(process_info.hProcess, INFINITE);
     
    314312        if (rc != WAIT_OBJECT_0) {
    315313                report_func_fail(test, "WaitForSingleObject(/* stdout reader thread */)");
    316                 return PCUT_ERROR_INTERNAL_FAILURE;
     314                return PCUT_OUTCOME_INTERNAL_ERROR;
    317315        }
    318316
     
    322320}
    323321
    324 void pcut_hook_before_test(pcut_item_t *test)
    325 {
     322void pcut_hook_before_test(pcut_item_t *test) {
    326323        PCUT_UNUSED(test);
    327324
  • uspace/lib/pcut/src/preproc.c

    r275530a4 r4b54bd9  
    2727 */
    2828
    29 #include <stdbool.h>
     29#pragma warning(push, 0)
    3030#include <stdio.h>
    3131#include <stdlib.h>
    3232#include <ctype.h>
    3333#include <string.h>
     34#pragma warning(pop)
     35
    3436
    3537#define MAX_IDENTIFIER_LENGTH 256
     
    3739static int counter = 0;
    3840
    39 static void print_numbered_identifier(int value, FILE *output)
    40 {
     41static void print_numbered_identifier(int value, FILE *output) {
    4142        fprintf(output, "pcut_item_%d", value);
    4243}
    4344
    44 static void print_numbered_identifier2(int value, FILE *output)
    45 {
     45static void print_numbered_identifier2(int value, FILE *output) {
    4646        fprintf(output, "pcut_item2_%d", value);
    4747}
    4848
    49 static void print_numbered_identifier3(int value, FILE *output)
    50 {
     49static void print_numbered_identifier3(int value, FILE *output) {
    5150        fprintf(output, "pcut_item3_%d", value);
    5251}
     
    5756} identifier_t;
    5857
    59 static void identifier_init(identifier_t *identifier)
    60 {
     58static void identifier_init(identifier_t *identifier) {
    6159        identifier->name[0] = 0;
    6260        identifier->length = 0;
    6361}
    6462
    65 static void identifier_add_char(identifier_t *identifier, char c)
    66 {
     63static void identifier_add_char(identifier_t *identifier, char c) {
    6764        if (identifier->length + 1 >= MAX_IDENTIFIER_LENGTH) {
    6865                fprintf(stderr, "Identifier %s is too long, aborting!\n", identifier->name);
     
    7572}
    7673
    77 static void identifier_print_or_expand(identifier_t *identifier, FILE *output)
    78 {
     74static void identifier_print_or_expand(identifier_t *identifier, FILE *output) {
    7975        const char *name = identifier->name;
    8076        if (strcmp(name, "PCUT_ITEM_NAME") == 0) {
     
    9389}
    9490
    95 static int is_identifier_char(int c, int inside_identifier)
    96 {
    97         return isalpha(c) || (c == '_') || (inside_identifier && isdigit(c));
     91static int is_identifier_char(int c, int inside_identifier) {
     92        return isalpha(c) || (c == '_')
     93                        || (inside_identifier && isdigit(c));
    9894}
    9995
    100 int main(int argc, char *argv[])
    101 {
     96int main(int argc, char *argv[]) {
    10297        FILE *input = stdin;
    10398        FILE *output = stdout;
     
    110105        (void) argv;
    111106
    112         while (true) {
     107        while (1) {
    113108                int current_char_denotes_identifier;
    114109
  • uspace/lib/pcut/src/print.c

    r275530a4 r4b54bd9  
    3333
    3434#include <pcut/pcut.h>
     35
     36#pragma warning(push, 0)
    3537#include <stdio.h>
    3638#include <stdlib.h>
    3739#include <assert.h>
     40#pragma warning(pop)
     41
    3842#include "internal.h"
    3943
     
    4246 * @param first First item to be printed.
    4347 */
    44 void pcut_print_items(pcut_item_t *first)
    45 {
     48void pcut_print_items(pcut_item_t *first) {
    4649        pcut_item_t *it = first;
    4750        printf("====>\n");
     
    7275 * @param first First item to be printed.
    7376 */
    74 void pcut_print_tests(pcut_item_t *first)
    75 {
     77void pcut_print_tests(pcut_item_t *first) {
    7678        pcut_item_t *it;
    7779        for (it = pcut_get_real(first); it != NULL; it = pcut_get_real_next(it)) {
  • uspace/lib/pcut/src/report/report.c

    r275530a4 r4b54bd9  
    3333
    3434#include "../internal.h"
     35
    3536#ifdef __helenos__
    36 #include <str.h>
     37#include <mem.h>
    3738#else
     39#pragma warning(push, 0)
    3840#include <string.h>
     41#pragma warning(pop)
    3942#endif
    40 #include <stdbool.h>
     43
     44#pragma warning(push, 0)
    4145#include <stdio.h>
     46#pragma warning(pop)
     47
    4248
    4349/** Currently used report ops. */
     
    6874 * @param msg The message to be printed.
    6975 */
    70 void pcut_print_fail_message(const char *msg)
    71 {
     76void pcut_print_fail_message(const char *msg) {
    7277        if (msg == NULL) {
    7378                return;
     
    99104 */
    100105static void parse_command_output(const char *full_output, size_t full_output_size,
    101     char *stdio_buffer, size_t stdio_buffer_size,
    102     char *error_buffer, size_t error_buffer_size)
    103 {
     106                char *stdio_buffer, size_t stdio_buffer_size,
     107                char *error_buffer, size_t error_buffer_size) {
    104108        memset(stdio_buffer, 0, stdio_buffer_size);
    105109        memset(error_buffer, 0, error_buffer_size);
     
    111115        }
    112116
    113         while (true) {
     117        while (1) {
    114118                size_t message_length;
    115119
     
    157161 * @param ops Functions to use.
    158162 */
    159 void pcut_report_register_handler(pcut_report_ops_t *ops)
    160 {
     163void pcut_report_register_handler(pcut_report_ops_t *ops) {
    161164        report_ops = ops;
    162165}
     
    166169 * @param all_items List of all tests that could be run.
    167170 */
    168 void pcut_report_init(pcut_item_t *all_items)
    169 {
     171void pcut_report_init(pcut_item_t *all_items) {
    170172        REPORT_CALL(init, all_items);
    171173}
     
    175177 * @param suite Suite that was just started.
    176178 */
    177 void pcut_report_suite_start(pcut_item_t *suite)
    178 {
     179void pcut_report_suite_start(pcut_item_t *suite) {
    179180        REPORT_CALL(suite_start, suite);
    180181}
     
    184185 * @param suite Suite that just completed.
    185186 */
    186 void pcut_report_suite_done(pcut_item_t *suite)
    187 {
     187void pcut_report_suite_done(pcut_item_t *suite) {
    188188        REPORT_CALL(suite_done, suite);
    189189}
     
    193193 * @param test Test to be run just about now.
    194194 */
    195 void pcut_report_test_start(pcut_item_t *test)
    196 {
     195void pcut_report_test_start(pcut_item_t *test) {
    197196        REPORT_CALL(test_start, test);
    198197}
     
    207206 */
    208207void pcut_report_test_done(pcut_item_t *test, int outcome,
    209     const char *error_message, const char *teardown_error_message,
    210     const char *extra_output)
    211 {
     208                const char *error_message, const char *teardown_error_message,
     209                const char *extra_output) {
    212210        REPORT_CALL(test_done, test, outcome, error_message, teardown_error_message,
    213             extra_output);
     211                        extra_output);
    214212}
    215213
     
    222220 */
    223221void pcut_report_test_done_unparsed(pcut_item_t *test, int outcome,
    224     const char *unparsed_output, size_t unparsed_output_size)
    225 {
     222                const char *unparsed_output, size_t unparsed_output_size) {
    226223
    227224        parse_command_output(unparsed_output, unparsed_output_size,
    228             buffer_for_extra_output, BUFFER_SIZE,
    229             buffer_for_error_messages, BUFFER_SIZE);
     225                        buffer_for_extra_output, BUFFER_SIZE,
     226                        buffer_for_error_messages, BUFFER_SIZE);
    230227
    231228        pcut_report_test_done(test, outcome, buffer_for_error_messages, NULL, buffer_for_extra_output);
     
    235232 *
    236233 */
    237 void pcut_report_done(void)
    238 {
     234void pcut_report_done(void) {
    239235        REPORT_CALL_NO_ARGS(done);
    240236}
  • uspace/lib/pcut/src/report/tap.c

    r275530a4 r4b54bd9  
    3434#include "../internal.h"
    3535#include "report.h"
     36
    3637#ifndef __helenos__
     38#pragma warning(push, 0)
    3739#include <string.h>
     40#pragma warning(pop)
    3841#endif
     42
     43#pragma warning(push, 0)
    3944#include <stdio.h>
     45#pragma warning(pop)
     46
    4047
    4148/** Counter of all run tests. */
     
    5562 * @param all_items Start of the list with all items.
    5663 */
    57 static void tap_init(pcut_item_t *all_items)
    58 {
     64static void tap_init(pcut_item_t *all_items) {
    5965        int tests_total = pcut_count_tests(all_items);
    6066        test_counter = 0;
     
    6874 * @param suite Suite that just started.
    6975 */
    70 static void tap_suite_start(pcut_item_t *suite)
    71 {
     76static void tap_suite_start(pcut_item_t *suite) {
    7277        tests_in_suite = 0;
    7378        failed_tests_in_suite = 0;
     
    8085 * @param suite Suite that just ended.
    8186 */
    82 static void tap_suite_done(pcut_item_t *suite)
    83 {
     87static void tap_suite_done(pcut_item_t *suite) {
    8488        if (failed_tests_in_suite == 0) {
    8589                printf("#> Finished suite %s (passed).\n",
    86                     suite->name);
     90                                suite->name);
    8791        } else {
    8892                printf("#> Finished suite %s (failed %d of %d).\n",
    89                     suite->name, failed_tests_in_suite, tests_in_suite);
     93                                suite->name, failed_tests_in_suite, tests_in_suite);
    9094        }
    9195}
     
    97101 * @param test Test that is started.
    98102 */
    99 static void tap_test_start(pcut_item_t *test)
    100 {
     103static void tap_test_start(pcut_item_t *test) {
    101104        PCUT_UNUSED(test);
    102105
     
    110113 * @param prefix Prefix for each new line, such as comment character.
    111114 */
    112 static void print_by_lines(const char *message, const char *prefix)
    113 {
     115static void print_by_lines(const char *message, const char *prefix) {
    114116        char *next_line_start;
    115117        if ((message == NULL) || (message[0] == 0)) {
     
    137139 */
    138140static void tap_test_done(pcut_item_t *test, int outcome,
    139     const char *error_message, const char *teardown_error_message,
    140     const char *extra_output)
    141 {
     141                const char *error_message, const char *teardown_error_message,
     142                const char *extra_output) {
    142143        const char *test_name = test->name;
    143144        const char *status_str = NULL;
     
    172173
    173174/** Report testing done. */
    174 static void tap_done(void)
    175 {
     175static void tap_done(void) {
    176176        if (failed_test_counter == 0) {
    177177                printf("#> Done: all tests passed.\n");
  • uspace/lib/pcut/src/report/xml.c

    r275530a4 r4b54bd9  
    3434#include "../internal.h"
    3535#include "report.h"
     36
    3637#ifndef __helenos__
     38#pragma warning(push, 0)
    3739#include <string.h>
     40#pragma warning(pop)
    3841#endif
     42
     43#pragma warning(push, 0)
    3944#include <stdio.h>
     45#pragma warning(pop)
     46
    4047
    4148/** Counter of all run tests. */
     
    5259 * @param all_items Start of the list with all items.
    5360 */
    54 static void xml_init(pcut_item_t *all_items)
    55 {
     61static void xml_init(pcut_item_t *all_items) {
    5662        int tests_total = pcut_count_tests(all_items);
    5763        test_counter = 0;
     
    6571 * @param suite Suite that just started.
    6672 */
    67 static void xml_suite_start(pcut_item_t *suite)
    68 {
     73static void xml_suite_start(pcut_item_t *suite) {
    6974        tests_in_suite = 0;
    7075        failed_tests_in_suite = 0;
     
    7782 * @param suite Suite that just ended.
    7883 */
    79 static void xml_suite_done(pcut_item_t *suite)
    80 {
     84static void xml_suite_done(pcut_item_t *suite) {
    8185        printf("\t</suite><!-- %s: %d / %d -->\n", suite->name,
    82             failed_tests_in_suite, tests_in_suite);
     86                failed_tests_in_suite, tests_in_suite);
    8387}
    8488
     
    8993 * @param test Test that is started.
    9094 */
    91 static void xml_test_start(pcut_item_t *test)
    92 {
     95static void xml_test_start(pcut_item_t *test) {
    9396        PCUT_UNUSED(test);
    9497
     
    102105 * @param element_name Wrapping XML element name.
    103106 */
    104 static void print_by_lines(const char *message, const char *element_name)
    105 {
     107static void print_by_lines(const char *message, const char *element_name) {
    106108        char *next_line_start;
    107109
     
    135137 */
    136138static void xml_test_done(pcut_item_t *test, int outcome,
    137     const char *error_message, const char *teardown_error_message,
    138     const char *extra_output)
    139 {
     139                const char *error_message, const char *teardown_error_message,
     140                const char *extra_output) {
    140141        const char *test_name = test->name;
    141142        const char *status_str = NULL;
     
    158159
    159160        printf("\t\t<testcase name=\"%s\" status=\"%s\">\n", test_name,
    160             status_str);
     161                status_str);
    161162
    162163        print_by_lines(error_message, "error-message");
     
    169170
    170171/** Report testing done. */
    171 static void xml_done(void)
    172 {
     172static void xml_done(void) {
    173173        printf("</report>\n");
    174174}
  • uspace/lib/pcut/src/run.c

    r275530a4 r4b54bd9  
    3333
    3434#include "internal.h"
     35
    3536#ifndef PCUT_NO_LONG_JUMP
     37#pragma warning(push, 0)
    3638#include <setjmp.h>
     39#pragma warning(pop)
    3740#endif
    3841
     
    7376static int default_suite_initialized = 0;
    7477
    75 static void init_default_suite_when_needed()
    76 {
     78static void init_default_suite_when_needed() {
    7779        if (default_suite_initialized) {
    7880                return;
     
    9294 * @return Always a valid test suite item.
    9395 */
    94 static pcut_item_t *pcut_find_parent_suite(pcut_item_t *it)
    95 {
     96static pcut_item_t *pcut_find_parent_suite(pcut_item_t *it) {
    9697        while (it != NULL) {
    9798                if (it->kind == PCUT_KIND_TESTSUITE) {
     
    108109 * @param func Function to run (can be NULL).
    109110 */
    110 static void run_setup_teardown(pcut_setup_func_t func)
    111 {
     111static void run_setup_teardown(pcut_setup_func_t func) {
    112112        if (func != NULL) {
    113113                func();
     
    122122 * @param outcome Outcome of the current test.
    123123 */
    124 static void leave_test(int outcome)
    125 {
     124static void leave_test(int outcome) {
    126125        PCUT_DEBUG("leave_test(outcome=%d), will_exit=%s", outcome,
    127             leave_means_exit ? "yes" : "no");
     126                leave_means_exit ? "yes" : "no");
    128127        if (leave_means_exit) {
    129128                exit(outcome);
     
    142141 * @param message Message describing the failure.
    143142 */
    144 void pcut_failed_assertion(const char *message)
    145 {
     143void pcut_failed_assertion(const char *message) {
    146144        static const char *prev_message = NULL;
    147145        /*
     
    162160                if (report_test_result) {
    163161                        pcut_report_test_done(current_test, PCUT_OUTCOME_FAIL,
    164                             message, NULL, NULL);
     162                                message, NULL, NULL);
    165163                }
    166164        } else {
    167165                if (report_test_result) {
    168166                        pcut_report_test_done(current_test, PCUT_OUTCOME_FAIL,
    169                             prev_message, message, NULL);
     167                                prev_message, message, NULL);
    170168                }
    171169        }
     
    181179 * @return Error status (zero means success).
    182180 */
    183 static int run_test(pcut_item_t *test)
    184 {
     181static int run_test(pcut_item_t *test) {
    185182        /*
    186183         * Set here as the returning point in case of test failure.
     
    234231        if (report_test_result) {
    235232                pcut_report_test_done(current_test, PCUT_OUTCOME_PASS,
    236                     NULL, NULL, NULL);
     233                        NULL, NULL, NULL);
    237234        }
    238235
     
    248245 * @return Error status (zero means success).
    249246 */
    250 int pcut_run_test_forked(pcut_item_t *test)
    251 {
     247int pcut_run_test_forked(pcut_item_t *test) {
    252248        int rc;
    253249
     
    272268 * @return Error status (zero means success).
    273269 */
    274 int pcut_run_test_single(pcut_item_t *test)
    275 {
     270int pcut_run_test_single(pcut_item_t *test) {
    276271        int rc;
    277272
     
    293288 * @return Timeout in seconds.
    294289 */
    295 int pcut_get_test_timeout(pcut_item_t *test)
    296 {
     290int pcut_get_test_timeout(pcut_item_t *test) {
    297291        int timeout = PCUT_DEFAULT_TEST_TIMEOUT;
    298292        pcut_extra_t *extras = test->extras;
Note: See TracChangeset for help on using the changeset viewer.