Changeset 9eb1ff5 in mainline for uspace/lib/pcut/src/os/unix.c


Ignore:
Timestamp:
2017-12-08T14:47:08Z (8 years ago)
Author:
Vojtech Horky <vojtech.horky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c1694b6b
Parents:
6fb8b2c
Message:

Update PCUT

Updated PCUT to commit 7ce059f.

Notable changes include:

  • overall summary is printed when tests finish
  • when tests passed, the status message does not use the word 'failure'
  • program exit code is zero only when all tests passed

These changes fixes tickets 713 and 714.

http://www.helenos.org/ticket/713
http://www.helenos.org/ticket/714

File:
1 edited

Legend:

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

    r6fb8b2c r9eb1ff5  
    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
    3842#include <stdlib.h>
    3943#include <unistd.h>
    40 #include <stddef.h>
     44#include <sys/types.h>
    4145#include <signal.h>
    4246#include <errno.h>
     
    120124        if (WIFEXITED(status)) {
    121125                if (WEXITSTATUS(status) != 0) {
    122                         return TEST_OUTCOME_FAIL;
     126                        return PCUT_OUTCOME_FAIL;
    123127                } else {
    124                         return TEST_OUTCOME_PASS;
     128                        return PCUT_OUTCOME_PASS;
    125129                }
    126130        }
    127131
    128132        if (WIFSIGNALED(status)) {
    129                 return TEST_OUTCOME_ERROR;
     133                return PCUT_OUTCOME_INTERNAL_ERROR;
    130134        }
    131135
     
    138142 * @param test Test to be run.
    139143 */
    140 void pcut_run_test_forking(const char *self_path, pcut_item_t *test) {
     144int pcut_run_test_forking(const char *self_path, pcut_item_t *test) {
    141145        int link_stdout[2], link_stderr[2];
    142         int rc, status;
     146        int rc, status, outcome;
    143147        size_t stderr_size;
    144148
     
    152156                snprintf(error_message_buffer, OUTPUT_BUFFER_SIZE - 1,
    153157                                "pipe() failed: %s.", strerror(rc));
    154                 pcut_report_test_done(test, TEST_OUTCOME_ERROR, error_message_buffer, NULL, NULL);
    155                 return;
     158                pcut_report_test_done(test, PCUT_OUTCOME_INTERNAL_ERROR, error_message_buffer, NULL, NULL);
     159                return PCUT_OUTCOME_INTERNAL_ERROR;
    156160        }
    157161        rc = pipe(link_stderr);
     
    159163                snprintf(error_message_buffer, OUTPUT_BUFFER_SIZE - 1,
    160164                                "pipe() failed: %s.", strerror(rc));
    161                 pcut_report_test_done(test, TEST_OUTCOME_ERROR, error_message_buffer, NULL, NULL);
    162                 return;
     165                pcut_report_test_done(test, PCUT_OUTCOME_INTERNAL_ERROR, error_message_buffer, NULL, NULL);
     166                return PCUT_OUTCOME_INTERNAL_ERROR;
    163167        }
    164168
     
    167171                snprintf(error_message_buffer, OUTPUT_BUFFER_SIZE - 1,
    168172                        "fork() failed: %s.", strerror(rc));
    169                 rc = TEST_OUTCOME_ERROR;
     173                outcome = PCUT_OUTCOME_INTERNAL_ERROR;
    170174                goto leave_close_pipes;
    171175        }
     
    178182                close(link_stderr[0]);
    179183
    180                 rc = pcut_run_test_forked(test);
    181 
    182                 exit(rc);
     184                outcome = pcut_run_test_forked(test);
     185
     186                exit(outcome);
    183187        }
    184188
     
    195199        alarm(0);
    196200
    197         rc = convert_wait_status_to_outcome(status);
     201        outcome = convert_wait_status_to_outcome(status);
    198202
    199203        goto leave_close_parent_pipe;
     
    206210        close(link_stderr[0]);
    207211
    208         pcut_report_test_done_unparsed(test, rc, extra_output_buffer, OUTPUT_BUFFER_SIZE);
     212        pcut_report_test_done_unparsed(test, outcome, extra_output_buffer, OUTPUT_BUFFER_SIZE);
     213
     214        return outcome;
    209215}
    210216
Note: See TracChangeset for help on using the changeset viewer.