Changeset 1433ecda in mainline for uspace/lib/pcut/src/os


Ignore:
Timestamp:
2018-04-04T15:42:37Z (8 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2c4e1cc
Parents:
47b2d7e3
Message:

Fix cstyle: make ccheck-fix and commit only files where all the changes are good.

Location:
uspace/lib/pcut/src/os
Files:
4 edited

Legend:

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

    r47b2d7e3 r1433ecda  
    8181 * @param test Test that is about to start.
    8282 */
    83 static void before_test_start(pcut_item_t *test) {
     83static void before_test_start(pcut_item_t *test)
     84{
    8485        pcut_report_test_start(test);
    8586
     
    9394 * @return Test outcome code.
    9495 */
    95 static int convert_wait_status_to_outcome(int status) {
     96static int convert_wait_status_to_outcome(int status)
     97{
    9698        if (status < 0) {
    9799                return PCUT_OUTCOME_INTERNAL_ERROR;
     
    108110 * @param test Test to be run.
    109111 */
    110 int pcut_run_test_forking(const char *self_path, pcut_item_t *test) {
     112int pcut_run_test_forking(const char *self_path, pcut_item_t *test)
     113{
    111114        int rc, outcome;
    112115        FILE *tempfile;
     
    118121        FORMAT_TEMP_FILENAME(tempfile_name, PCUT_TEMP_FILENAME_BUFFER_SIZE - 1);
    119122        FORMAT_COMMAND(command, PCUT_COMMAND_LINE_BUFFER_SIZE - 1,
    120                 self_path, (test)->id, tempfile_name);
     123            self_path, (test)->id, tempfile_name);
    121124
    122125        PCUT_DEBUG("Will execute <%s> (temp file <%s>) with system().",
    123                 command, tempfile_name);
     126            command, tempfile_name);
    124127
    125128        rc = system(command);
     
    144147}
    145148
    146 void pcut_hook_before_test(pcut_item_t *test) {
     149void pcut_hook_before_test(pcut_item_t *test)
     150{
    147151        PCUT_UNUSED(test);
    148152
  • uspace/lib/pcut/src/os/stdc.c

    r47b2d7e3 r1433ecda  
    3535#include "../internal.h"
    3636
    37 int pcut_str_equals(const char *a, const char *b) {
     37int pcut_str_equals(const char *a, const char *b)
     38{
    3839        return strcmp(a, b) == 0;
    3940}
    4041
    41 int pcut_str_start_equals(const char *a, const char *b, int len) {
     42int pcut_str_start_equals(const char *a, const char *b, int len)
     43{
    4244        return strncmp(a, b, len) == 0;
    4345}
    4446
    45 int pcut_str_size(const char *s) {
     47int pcut_str_size(const char *s)
     48{
    4649        return strlen(s);
    4750}
    4851
    49 int pcut_str_to_int(const char *s) {
     52int pcut_str_to_int(const char *s)
     53{
    5054        return atoi(s);
    5155}
    5256
    53 char *pcut_str_find_char(const char *haystack, const char needle) {
     57char *pcut_str_find_char(const char *haystack, const char needle)
     58{
    5459        return strchr(haystack, needle);
    5560}
    5661
    57 void pcut_str_error(int error, char *buffer, int size) {
     62void pcut_str_error(int error, char *buffer, int size)
     63{
    5864        const char *str = strerror(error);
    5965        if (str == NULL) {
  • uspace/lib/pcut/src/os/unix.c

    r47b2d7e3 r1433ecda  
    6464 * @param test Test that is about to be run.
    6565 */
    66 static void before_test_start(pcut_item_t *test) {
     66static void before_test_start(pcut_item_t *test)
     67{
    6768        pcut_report_test_start(test);
    6869
     
    7879 * @param sig Signal number.
    7980 */
    80 static void kill_child_on_alarm(int sig) {
     81static void kill_child_on_alarm(int sig)
     82{
    8183        PCUT_UNUSED(sig);
    8284        kill(child_pid, SIGKILL);
     
    9496 * @return Number of actually read bytes.
    9597 */
    96 static size_t read_all(int fd, char *buffer, size_t buffer_size) {
     98static size_t read_all(int fd, char *buffer, size_t buffer_size)
     99{
    97100        ssize_t actually_read;
    98101        char *buffer_start = buffer;
     
    121124 * @return Test outcome code.
    122125 */
    123 static int convert_wait_status_to_outcome(int status) {
     126static int convert_wait_status_to_outcome(int status)
     127{
    124128        if (WIFEXITED(status)) {
    125129                if (WEXITSTATUS(status) != 0) {
     
    142146 * @param test Test to be run.
    143147 */
    144 int pcut_run_test_forking(const char *self_path, pcut_item_t *test) {
     148int pcut_run_test_forking(const char *self_path, pcut_item_t *test)
     149{
    145150        int link_stdout[2], link_stderr[2];
    146151        int rc, status, outcome;
     
    155160        if (rc == -1) {
    156161                snprintf(error_message_buffer, OUTPUT_BUFFER_SIZE - 1,
    157                                 "pipe() failed: %s.", strerror(rc));
     162                    "pipe() failed: %s.", strerror(rc));
    158163                pcut_report_test_done(test, PCUT_OUTCOME_INTERNAL_ERROR, error_message_buffer, NULL, NULL);
    159164                return PCUT_OUTCOME_INTERNAL_ERROR;
     
    162167        if (rc == -1) {
    163168                snprintf(error_message_buffer, OUTPUT_BUFFER_SIZE - 1,
    164                                 "pipe() failed: %s.", strerror(rc));
     169                    "pipe() failed: %s.", strerror(rc));
    165170                pcut_report_test_done(test, PCUT_OUTCOME_INTERNAL_ERROR, error_message_buffer, NULL, NULL);
    166171                return PCUT_OUTCOME_INTERNAL_ERROR;
     
    170175        if (child_pid == (pid_t)-1) {
    171176                snprintf(error_message_buffer, OUTPUT_BUFFER_SIZE - 1,
    172                         "fork() failed: %s.", strerror(rc));
     177                    "fork() failed: %s.", strerror(rc));
    173178                outcome = PCUT_OUTCOME_INTERNAL_ERROR;
    174179                goto leave_close_pipes;
     
    215220}
    216221
    217 void pcut_hook_before_test(pcut_item_t *test) {
     222void pcut_hook_before_test(pcut_item_t *test)
     223{
    218224        PCUT_UNUSED(test);
    219225
  • uspace/lib/pcut/src/os/windows.c

    r47b2d7e3 r1433ecda  
    6161 * @param test Test that is about to be run.
    6262 */
    63 static void before_test_start(pcut_item_t *test) {
     63static void before_test_start(pcut_item_t *test)
     64{
    6465        pcut_report_test_start(test);
    6566
     
    7374 * @param failed_function_name Name of the failed function.
    7475 */
    75 static void report_func_fail(pcut_item_t *test, const char *failed_function_name) {
     76static void report_func_fail(pcut_item_t *test, const char *failed_function_name)
     77{
    7678        /* TODO: get error description. */
    7779        sprintf_s(error_message_buffer, OUTPUT_BUFFER_SIZE - 1,
    78                 "%s failed: %s.", failed_function_name, "unknown reason");
     80            "%s failed: %s.", failed_function_name, "unknown reason");
    7981        pcut_report_test_done(test, TEST_OUTCOME_ERROR, error_message_buffer, NULL, NULL);
    8082}
     
    9193 * @return Number of actually read bytes.
    9294 */
    93 static size_t read_all(HANDLE fd, char *buffer, size_t buffer_size) {
     95static size_t read_all(HANDLE fd, char *buffer, size_t buffer_size)
     96{
    9497        DWORD actually_read;
    9598        char *buffer_start = buffer;
     
    125128};
    126129
    127 static DWORD WINAPI read_test_output_on_background(LPVOID test_output_data_ptr) {
     130static DWORD WINAPI read_test_output_on_background(LPVOID test_output_data_ptr)
     131{
    128132        size_t stderr_size = 0;
    129133        struct test_output_data *test_output_data = (struct test_output_data *) test_output_data_ptr;
    130134
    131135        stderr_size = read_all(test_output_data->pipe_stderr,
    132                 test_output_data->output_buffer,
    133                 test_output_data->output_buffer_size - 1);
     136            test_output_data->output_buffer,
     137            test_output_data->output_buffer_size - 1);
    134138        read_all(test_output_data->pipe_stdout,
    135                 test_output_data->output_buffer,
    136                 test_output_data->output_buffer_size - 1 - stderr_size);
     139            test_output_data->output_buffer,
     140            test_output_data->output_buffer_size - 1 - stderr_size);
    137141
    138142        return 0;
     
    144148 * @param test Test to be run.
    145149 */
    146 int pcut_run_test_forking(const char *self_path, pcut_item_t *test) {
     150int pcut_run_test_forking(const char *self_path, pcut_item_t *test)
     151{
    147152        /* TODO: clean-up if something goes wrong "in the middle" */
    148153        BOOL okay = FALSE;
     
    216221        /* Format the command line. */
    217222        sprintf_s(command, PCUT_COMMAND_LINE_BUFFER_SIZE - 1,
    218                 "\"%s\" -t%d", self_path, test->id);
     223            "\"%s\" -t%d", self_path, test->id);
    219224
    220225        /* Run the process. */
    221226        okay = CreateProcess(NULL, command, NULL, NULL, TRUE, 0, NULL, NULL,
    222                 &start_info, &process_info);
     227            &start_info, &process_info);
    223228
    224229        if (!okay) {
     
    262267
    263268        test_output_thread_reader = CreateThread(NULL, 0,
    264                 read_test_output_on_background, &test_output_data,
    265                 0, NULL);
     269            read_test_output_on_background, &test_output_data,
     270            0, NULL);
    266271
    267272        if (test_output_thread_reader == NULL) {
     
    317322}
    318323
    319 void pcut_hook_before_test(pcut_item_t *test) {
     324void pcut_hook_before_test(pcut_item_t *test)
     325{
    320326        PCUT_UNUSED(test);
    321327
Note: See TracChangeset for help on using the changeset viewer.