summaryrefslogtreecommitdiff
path: root/test/regression/interoperability_test/test_frame/tls_test_instance_attributes_access.c
blob: f11a0b3460e3951403af2d6f1fae8d46ab48e05e (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
45
46
47
48
49
50
51
52
53
54
55
56
/***************************************************************************/
/* 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"

/* Get the name of the instance. */
INT tls_test_instance_get_name( TLS_TEST_INSTANCE* instance_ptr, CHAR** name_ptr)
{
    *name_ptr = instance_ptr -> tls_test_instance_name;
    return_value_if_fail(NULL != *name_ptr, TLS_TEST_UNKNOWN_TYPE_ERROR);
    return TLS_TEST_SUCCESS;
}

/* Get the exit code of the instance. */
INT tls_test_instance_get_exit_status( TLS_TEST_INSTANCE* instance_ptr, INT* exit_status_ptr)
{
    *exit_status_ptr = instance_ptr -> tls_test_instance_exit_status;
    return TLS_TEST_SUCCESS;
}

/* Print the comments of the exit status of test instances. */
INT tls_test_instance_show_exit_status(TLS_TEST_INSTANCE* instance_ptr)
{
INT         status, exit_status;
CHAR        *name;

    /* Check instance pointer. */
    return_value_if_fail(NULL != instance_ptr, TLS_TEST_INVALID_POINTER);

    /* Ensure that the test instance is exited or signaled. */
    return_value_if_fail(instance_ptr -> tls_test_instance_status & (TLS_TEST_INSTANCE_STATUS_EXITED | TLS_TEST_INSTANCE_STATUS_SIGNALED), TLS_TEST_INSTANCE_UNEXITED);

    status = tls_test_instance_get_exit_status(instance_ptr, &exit_status);
    return_value_if_fail(TLS_TEST_SUCCESS == status, status);

    status = tls_test_instance_get_name(instance_ptr, &name);
    return_value_if_fail(TLS_TEST_SUCCESS == status, status);

    if (0 <= exit_status)
    {
        print_error_message("Instance %s exited with return code %d.\n", name, exit_status);
    }
    else if (0 > exit_status)
    {
        print_error_message("Instance %s is killed by signal %d.\n", name, -exit_status);
    }
    return TLS_TEST_SUCCESS;
}