1 /*
2  * Copyright (C) 2018 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include <app_mgmt_port_consts.h>
18 #include <app_mgmt_test.h>
19 #include <stddef.h>
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <string.h>
23 #include <trusty_ipc.h>
24 #include <uapi/err.h>
25 
26 #define TLOG_TAG "restart-srv"
27 
28 /* Resources are intentionally not freed to test application cleanup on exit */
main(void)29 int main(void) {
30     int rc;
31     handle_t restart_port;
32     uevent_t uevt;
33 
34     rc = port_create(RESTART_PORT, 1, 1, IPC_PORT_ALLOW_TA_CONNECT);
35     if (rc < 0) {
36         TLOGI("failed (%d) to create ctrl port\n", rc);
37         return rc;
38     }
39 
40     restart_port = (handle_t)rc;
41 
42     rc = wait(restart_port, &uevt, INFINITE_TIME);
43     if (rc != NO_ERROR || !(uevt.event & IPC_HANDLE_POLL_READY)) {
44         TLOGI("Port wait failed: %d(%d)\n", rc, uevt.event);
45         return rc;
46     }
47 
48     return 0;
49 }
50