1 // SPDX-License-Identifier: BSD-2-Clause
2 /*
3  * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
4  */
5 
6 #include <service/test_runner/client/cpp/test_runner_client.h>
7 #include <app/remote-test-runner/remote_test_runner.h>
8 #include <protocols/rpc/common/packed-c/encoding.h>
9 #include <service_locator.h>
10 #include <rpc_caller.h>
11 #include <cstdio>
12 
main(int argc,char * argv[])13 int main(int argc, char *argv[]) {
14 	(void) argc;
15 	(void) argv;
16 
17 	int status = -1;
18 	struct service_context *test_runner_service_context = NULL;
19 
20 	service_locator_init();
21 
22 	test_runner_service_context = service_locator_query("sn:trustedfirmware.org:test-runner:0");
23 
24 	if (test_runner_service_context) {
25 
26 		struct rpc_caller_session *session = NULL;
27 
28 		session = service_context_open(test_runner_service_context);
29 
30 		if (session) {
31 
32 			test_runner_client test_runner_client(session);
33 			remote_test_runner commandline_runner(&test_runner_client);
34 
35 			status = commandline_runner.execute(argc, argv);
36 
37 			if (status != 0) {
38 				printf("Command failed with test status: %d rpc status: %d\n", status, test_runner_client.err_rpc_status());
39 			}
40 
41 			service_context_close(test_runner_service_context, session);
42 		}
43 		else {
44 			printf("Failed to open rpc session\n");
45 		}
46 
47 		service_context_relinquish(test_runner_service_context);
48 	}
49 	else {
50 		printf("Failed to discover test_runner service\n");
51 	}
52 
53 	return status;
54 }
55