Changeset 9b20126 in mainline for uspace/lib/pcut/src/os


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/src/os
Files:
1 added
3 edited

Legend:

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

    r15d0046 r9b20126  
    3333
    3434#include <stdlib.h>
     35#include <stdio.h>
    3536#include <sys/types.h>
    3637#include <errno.h>
     
    5051/* Format the command to launch a test according to OS we are running on. */
    5152
    52 #if defined(__WIN64) || defined(__WIN32)
     53#if defined(__WIN64) || defined(__WIN32) || defined(_WIN32)
    5354#include <process.h>
    5455
     
    108109 */
    109110void pcut_run_test_forking(const char *self_path, pcut_item_t *test) {
     111        int rc;
     112        FILE *tempfile;
     113        char tempfile_name[PCUT_TEMP_FILENAME_BUFFER_SIZE];
     114        char command[PCUT_COMMAND_LINE_BUFFER_SIZE];
     115
    110116        before_test_start(test);
    111117
    112         char tempfile_name[PCUT_TEMP_FILENAME_BUFFER_SIZE];
    113118        FORMAT_TEMP_FILENAME(tempfile_name, PCUT_TEMP_FILENAME_BUFFER_SIZE - 1);
    114 
    115         char command[PCUT_COMMAND_LINE_BUFFER_SIZE];
    116119        FORMAT_COMMAND(command, PCUT_COMMAND_LINE_BUFFER_SIZE - 1,
    117120                self_path, (test)->id, tempfile_name);
     121       
     122        PCUT_DEBUG("Will execute <%s> (temp file <%s>) with system().",
     123                command, tempfile_name);
    118124
    119         int rc = system(command);
     125        rc = system(command);
     126
     127        PCUT_DEBUG("system() returned 0x%04X", rc);
     128
    120129        rc = convert_wait_status_to_outcome(rc);
    121130
    122         FILE *tempfile = fopen(tempfile_name, "rb");
     131        tempfile = fopen(tempfile_name, "rb");
    123132        if (tempfile == NULL) {
    124133                pcut_report_test_done(test, TEST_OUTCOME_ERROR, "Failed to open temporary file.", NULL, NULL);
     
    133142}
    134143
     144void pcut_hook_before_test(pcut_item_t *test) {
     145        PCUT_UNUSED(test);
     146
     147        /* Do nothing. */
     148}
     149
  • uspace/lib/pcut/src/os/helenos.c

    r15d0046 r9b20126  
    185185        int status = TEST_OUTCOME_PASS;
    186186
    187         int rc = task_spawnvf(&test_task_id, self_path, arguments, files);
     187        task_wait_t test_task_wait;
     188        int rc = task_spawnvf(&test_task_id, &test_task_wait, self_path, arguments, files);
    188189        if (rc != EOK) {
    189190                status = TEST_OUTCOME_ERROR;
     
    203204        task_exit_t task_exit;
    204205        int task_retval;
    205         rc = task_wait(test_task_id, &task_exit, &task_retval);
     206        rc = task_wait(&test_task_wait, &task_exit, &task_retval);
    206207        if (rc != EOK) {
    207208                status = TEST_OUTCOME_ERROR;
     
    227228        pcut_report_test_done_unparsed(test, status, extra_output_buffer, OUTPUT_BUFFER_SIZE);
    228229}
     230
     231void pcut_hook_before_test(pcut_item_t *test) {
     232        PCUT_UNUSED(test);
     233
     234        /* Do nothing. */
     235}
  • uspace/lib/pcut/src/os/unix.c

    r15d0046 r9b20126  
    3232 */
    3333
    34 /** We need _POSX_SOURCE because of kill(). */
     34/** We need _POSIX_SOURCE because of kill(). */
    3535#define _POSIX_SOURCE
     36/** We need _BSD_SOURCE because of snprintf() when compiling under C89. */
     37#define _BSD_SOURCE
    3638#include <stdlib.h>
    3739#include <unistd.h>
     
    137139 */
    138140void pcut_run_test_forking(const char *self_path, pcut_item_t *test) {
     141        int link_stdout[2], link_stderr[2];
     142        int rc, status;
     143        size_t stderr_size;
     144
    139145        PCUT_UNUSED(self_path);
    140146
    141147        before_test_start(test);
    142148
    143         int link_stdout[2], link_stderr[2];
    144 
    145         int rc = pipe(link_stdout);
     149
     150        rc = pipe(link_stdout);
    146151        if (rc == -1) {
    147152                snprintf(error_message_buffer, OUTPUT_BUFFER_SIZE - 1,
     
    184189        alarm(pcut_get_test_timeout(test));
    185190
    186         size_t stderr_size = read_all(link_stderr[0], extra_output_buffer, OUTPUT_BUFFER_SIZE - 1);
     191        stderr_size = read_all(link_stderr[0], extra_output_buffer, OUTPUT_BUFFER_SIZE - 1);
    187192        read_all(link_stdout[0], extra_output_buffer, OUTPUT_BUFFER_SIZE - 1 - stderr_size);
    188193
    189         int status;
    190194        wait(&status);
    191195        alarm(0);
     
    204208        pcut_report_test_done_unparsed(test, rc, extra_output_buffer, OUTPUT_BUFFER_SIZE);
    205209}
     210
     211void pcut_hook_before_test(pcut_item_t *test) {
     212        PCUT_UNUSED(test);
     213
     214        /* Do nothing. */
     215}
     216
Note: See TracChangeset for help on using the changeset viewer.