Changeset 4b54bd9 in mainline for uspace/lib/pcut/src/os/windows.c


Ignore:
Timestamp:
2018-09-12T13:23:03Z (6 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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.