Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/pcut/src/os/unix.c

    r9eb1ff5 r8d2dd7f2  
    3636/** We need _BSD_SOURCE because of snprintf() when compiling under C89. */
    3737#define _BSD_SOURCE
    38 
    39 /** Newer versions of features.h needs _DEFAULT_SOURCE. */
    40 #define _DEFAULT_SOURCE
    41 
    4238#include <stdlib.h>
    4339#include <unistd.h>
    44 #include <sys/types.h>
     40#include <stddef.h>
    4541#include <signal.h>
    4642#include <errno.h>
     
    124120        if (WIFEXITED(status)) {
    125121                if (WEXITSTATUS(status) != 0) {
    126                         return PCUT_OUTCOME_FAIL;
     122                        return TEST_OUTCOME_FAIL;
    127123                } else {
    128                         return PCUT_OUTCOME_PASS;
     124                        return TEST_OUTCOME_PASS;
    129125                }
    130126        }
    131127
    132128        if (WIFSIGNALED(status)) {
    133                 return PCUT_OUTCOME_INTERNAL_ERROR;
     129                return TEST_OUTCOME_ERROR;
    134130        }
    135131
     
    142138 * @param test Test to be run.
    143139 */
    144 int pcut_run_test_forking(const char *self_path, pcut_item_t *test) {
     140void pcut_run_test_forking(const char *self_path, pcut_item_t *test) {
    145141        int link_stdout[2], link_stderr[2];
    146         int rc, status, outcome;
     142        int rc, status;
    147143        size_t stderr_size;
    148144
     
    156152                snprintf(error_message_buffer, OUTPUT_BUFFER_SIZE - 1,
    157153                                "pipe() failed: %s.", strerror(rc));
    158                 pcut_report_test_done(test, PCUT_OUTCOME_INTERNAL_ERROR, error_message_buffer, NULL, NULL);
    159                 return PCUT_OUTCOME_INTERNAL_ERROR;
     154                pcut_report_test_done(test, TEST_OUTCOME_ERROR, error_message_buffer, NULL, NULL);
     155                return;
    160156        }
    161157        rc = pipe(link_stderr);
     
    163159                snprintf(error_message_buffer, OUTPUT_BUFFER_SIZE - 1,
    164160                                "pipe() failed: %s.", strerror(rc));
    165                 pcut_report_test_done(test, PCUT_OUTCOME_INTERNAL_ERROR, error_message_buffer, NULL, NULL);
    166                 return PCUT_OUTCOME_INTERNAL_ERROR;
     161                pcut_report_test_done(test, TEST_OUTCOME_ERROR, error_message_buffer, NULL, NULL);
     162                return;
    167163        }
    168164
     
    171167                snprintf(error_message_buffer, OUTPUT_BUFFER_SIZE - 1,
    172168                        "fork() failed: %s.", strerror(rc));
    173                 outcome = PCUT_OUTCOME_INTERNAL_ERROR;
     169                rc = TEST_OUTCOME_ERROR;
    174170                goto leave_close_pipes;
    175171        }
     
    182178                close(link_stderr[0]);
    183179
    184                 outcome = pcut_run_test_forked(test);
    185 
    186                 exit(outcome);
     180                rc = pcut_run_test_forked(test);
     181
     182                exit(rc);
    187183        }
    188184
     
    199195        alarm(0);
    200196
    201         outcome = convert_wait_status_to_outcome(status);
     197        rc = convert_wait_status_to_outcome(status);
    202198
    203199        goto leave_close_parent_pipe;
     
    210206        close(link_stderr[0]);
    211207
    212         pcut_report_test_done_unparsed(test, outcome, extra_output_buffer, OUTPUT_BUFFER_SIZE);
    213 
    214         return outcome;
     208        pcut_report_test_done_unparsed(test, rc, extra_output_buffer, OUTPUT_BUFFER_SIZE);
    215209}
    216210
Note: See TracChangeset for help on using the changeset viewer.