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
|
/***************************************************************************/
/* 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 "mqtt_interoperability_test.h"
/* Global semaphore address. */
extern TLS_TEST_SEMAPHORE* semaphore_mqtt_topic_subscribed;
extern TLS_TEST_SEMAPHORE* semaphore_mqtt_message_published;
INT mqtt_publisher_entry(TLS_TEST_INSTANCE* instance_ptr)
{
CHAR* name;
/* Publish a messge to the test topic. */
CHAR* external_cmd[] = { "no_tls_pub.sh","-p", STRING(MQTT_PORT), "-t", "test", "-m", "hello", NULL};
INT status, exit_status;
/* Get the name of the test instance. */
status = tls_test_instance_get_name(instance_ptr, &name);
return_value_if_fail(TLS_TEST_SUCCESS == status, status);
/* Wait for the subscriber. */
tls_test_semaphore_wait(semaphore_mqtt_topic_subscribed);
/* Wait for subscriber for one seconds. */
tls_test_sleep(1);
print_error_message("Instance %s: get semaphore_mqtt_topic_subscribed.\n", name);
/* Call an external script in the directory prepared_test_program. */
status = tls_test_launch_external_test_process(&exit_status, external_cmd);
return_value_if_fail(TLS_TEST_SUCCESS == status, status);
/* Post the semaphore to indicate that one message is published. */
tls_test_sleep(1);
tls_test_semaphore_post(semaphore_mqtt_message_published);
/* Check for exit status of the external script. */
return_value_if_fail(0 == exit_status, TLS_TEST_INSTANCE_FAILED);
return 0;
};
|