summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Hall2018-05-23 18:22:46 -0500
committerJesse Hall2018-05-23 18:45:48 -0500
commit2576a439e6c4a750e001e70d73a33d9519bb7660 (patch)
tree258eea596705e2709354471eace7f3b135c1cfac /libsync
parent8cf185e5429523055c4de6c71deabd603b95b2de (diff)
downloadplatform-system-core-2576a439e6c4a750e001e70d73a33d9519bb7660.tar.gz
platform-system-core-2576a439e6c4a750e001e70d73a33d9519bb7660.tar.xz
platform-system-core-2576a439e6c4a750e001e70d73a33d9519bb7660.zip
Remove obsolete sync_test.c
Tests in this file depends on long out-of-date behavior of the sync api. More current tests are in tests/sync_test.cpp. Test: quis custodiet ipsos custodes? Change-Id: Ia0a0970dde17c1ae4e1d79fac1a9fe3b54e8fcd6
Diffstat (limited to 'libsync')
-rw-r--r--libsync/Android.bp7
-rw-r--r--libsync/sync_test.c147
2 files changed, 0 insertions, 154 deletions
diff --git a/libsync/Android.bp b/libsync/Android.bp
index 3fae5e669..c95563dff 100644
--- a/libsync/Android.bp
+++ b/libsync/Android.bp
@@ -40,13 +40,6 @@ cc_library_static {
40} 40}
41 41
42cc_test { 42cc_test {
43 name: "sync_test",
44 defaults: ["libsync_defaults"],
45 gtest: false,
46 srcs: ["sync_test.c"],
47}
48
49cc_test {
50 name: "sync-unit-tests", 43 name: "sync-unit-tests",
51 shared_libs: ["libsync"], 44 shared_libs: ["libsync"],
52 srcs: ["tests/sync_test.cpp"], 45 srcs: ["tests/sync_test.cpp"],
diff --git a/libsync/sync_test.c b/libsync/sync_test.c
deleted file mode 100644
index f1ffdcf9e..000000000
--- a/libsync/sync_test.c
+++ /dev/null
@@ -1,147 +0,0 @@
1/*
2 * sync_test.c
3 *
4 * Copyright 2012 Google, Inc
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19#include <errno.h>
20#include <pthread.h>
21#include <stdio.h>
22#include <string.h>
23#include <unistd.h>
24
25#include <android/sync.h>
26#include "sw_sync.h"
27
28pthread_mutex_t printf_mutex = PTHREAD_MUTEX_INITIALIZER;
29
30struct sync_thread_data {
31 int thread_no;
32 int fd[2];
33};
34
35void *sync_thread(void *data)
36{
37 struct sync_thread_data *sync_data = data;
38 struct sync_fence_info_data *info;
39 int err;
40 int i;
41
42 for (i = 0; i < 2; i++) {
43 err = sync_wait(sync_data->fd[i], 10000);
44
45 pthread_mutex_lock(&printf_mutex);
46 if (err < 0) {
47 printf("thread %d wait %d failed: %s\n", sync_data->thread_no,
48 i, strerror(errno));
49 } else {
50 printf("thread %d wait %d done\n", sync_data->thread_no, i);
51 }
52 info = sync_fence_info(sync_data->fd[i]);
53 if (info) {
54 struct sync_pt_info *pt_info = NULL;
55 printf(" fence %s %d\n", info->name, info->status);
56
57 while ((pt_info = sync_pt_info(info, pt_info))) {
58 int ts_sec = pt_info->timestamp_ns / 1000000000LL;
59 int ts_usec = (pt_info->timestamp_ns % 1000000000LL) / 1000LL;
60 printf(" pt %s %s %d %d.%06d", pt_info->obj_name,
61 pt_info->driver_name, pt_info->status,
62 ts_sec, ts_usec);
63 if (!strcmp(pt_info->driver_name, "sw_sync"))
64 printf(" val=%d\n", *(uint32_t *)pt_info->driver_data);
65 else
66 printf("\n");
67 }
68 sync_fence_info_free(info);
69 }
70 pthread_mutex_unlock(&printf_mutex);
71 }
72
73 return NULL;
74}
75
76int main(int argc __attribute__((unused)), char *argv[] __attribute__((unused)))
77{
78 struct sync_thread_data sync_data[4];
79 pthread_t threads[4];
80 int sync_timeline_fd;
81 int i, j;
82 char str[256];
83
84 sync_timeline_fd = sw_sync_timeline_create();
85 if (sync_timeline_fd < 0) {
86 perror("can't create sw_sync_timeline:");
87 return 1;
88 }
89
90 for (i = 0; i < 3; i++) {
91 sync_data[i].thread_no = i;
92
93 for (j = 0; j < 2; j++) {
94 unsigned val = i + j * 3 + 1;
95 snprintf(str, sizeof(str), "test_fence%d-%d", i, j);
96 int fd = sw_sync_fence_create(sync_timeline_fd, str, val);
97 if (fd < 0) {
98 printf("can't create sync pt %d: %s", val, strerror(errno));
99 return 1;
100 }
101 sync_data[i].fd[j] = fd;
102 printf("sync_data[%d].fd[%d] = %d;\n", i, j, fd);
103
104 }
105 }
106
107 sync_data[3].thread_no = 3;
108 for (j = 0; j < 2; j++) {
109 snprintf(str, sizeof(str), "merged_fence%d", j);
110 sync_data[3].fd[j] = sync_merge(str, sync_data[0].fd[j], sync_data[1].fd[j]);
111 if (sync_data[3].fd[j] < 0) {
112 printf("can't merge sync pts %d and %d: %s\n",
113 sync_data[0].fd[j], sync_data[1].fd[j], strerror(errno));
114 return 1;
115 }
116 }
117
118 for (i = 0; i < 4; i++)
119 pthread_create(&threads[i], NULL, sync_thread, &sync_data[i]);
120
121
122 for (i = 0; i < 3; i++) {
123 int err;
124 printf("press enter to inc to %d\n", i+1);
125 fgets(str, sizeof(str), stdin);
126 err = sw_sync_timeline_inc(sync_timeline_fd, 1);
127 if (err < 0) {
128 perror("can't increment sync obj:");
129 return 1;
130 }
131 }
132
133 printf("press enter to close sync_timeline\n");
134 fgets(str, sizeof(str), stdin);
135
136 close(sync_timeline_fd);
137
138 printf("press enter to end test\n");
139 fgets(str, sizeof(str), stdin);
140
141 for (i = 0; i < 3; i++) {
142 void *val;
143 pthread_join(threads[i], &val);
144 }
145
146 return 0;
147}