summaryrefslogtreecommitdiff
path: root/test/regression/interoperability_test/test_frame/tls_test_instance_set_exit_status.c
blob: 95109451435b47105c5f2932c0d61bb0fc38e2ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/***************************************************************************/
/* Copyright (c) 2024 Microsoft Corporation                                */
/* Copyright (c) 2026 Eclipse ThreadX contributors                         */
/*                                                                         */
/* This program and the accompanying materials are made available under    */
/* the terms of the MIT License which is available at                      */
/* https://opensource.org/licenses/MIT.                                    */
/*                                                                         */
/* SPDX-License-Identifier: MIT                                            */
/***************************************************************************/

#include "tls_test_frame.h"

/* Set the exit status of the test instance. */
/* The argument of exit_status must be set by system call of wait or waitpid. */
INT tls_test_instance_set_exit_status( TLS_TEST_INSTANCE* instance_ptr, INT exit_status)
{

    /* Check for pointers. */
    return_value_if_fail( NULL != instance_ptr, TLS_TEST_INVALID_POINTER);

    /* Clear running flag. */
    instance_ptr -> tls_test_instance_status &= ~TLS_TEST_INSTANCE_STATUS_RUNNING;
    instance_ptr -> tls_test_instance_exit_status = 0;

    /* Set the exit_status member of the test instance. */
    if ( WIFEXITED( exit_status))
    {
        instance_ptr -> tls_test_instance_status |= TLS_TEST_INSTANCE_STATUS_EXITED;
        instance_ptr -> tls_test_instance_exit_status = WEXITSTATUS( exit_status);
    }
    else if ( WIFSIGNALED( exit_status))
    {
        instance_ptr -> tls_test_instance_status |= TLS_TEST_INSTANCE_STATUS_SIGNALED;
        instance_ptr -> tls_test_instance_exit_status = -WTERMSIG( exit_status);
    }
    else
    {
        /* unresolvable exit status. */
        return TLS_TEST_UNKNOWN_TYPE_ERROR;
    }

    return TLS_TEST_SUCCESS;
}