Lines Matching refs:wb

39 bool check_for_empty(watch_buffer_t* wb, const zx::channel& c) {
41 ASSERT_NULL(wb->ptr);
46 bool check_local_event(watch_buffer_t* wb, const char* expected, uint8_t event) {
48 if (wb->ptr != nullptr) {
50 ASSERT_EQ(wb->ptr[0], event);
51 ASSERT_EQ(wb->ptr[1], expected_len);
52 ASSERT_EQ(memcmp(wb->ptr + 2, expected, expected_len), 0);
53 wb->ptr = (uint8_t*)((uintptr_t)(wb->ptr) + expected_len + 2);
54 ASSERT_LE((uintptr_t)wb->ptr, (uintptr_t) wb->buf + wb->size);
55 if ((uintptr_t) wb->ptr == (uintptr_t) wb->buf + wb->size) {
56 wb->ptr = nullptr;
64 bool check_for_event(watch_buffer_t* wb, const zx::channel& c, const char* expected,
66 if (wb->ptr != nullptr) {
67 return check_local_event(wb, expected, event);
74 ASSERT_EQ(c.read(0, wb->buf, sizeof(wb->buf), &actual, nullptr, 0, nullptr), ZX_OK);
75 wb->size = actual;
76 wb->ptr = wb->buf;
77 return check_local_event(wb, expected, event);
98 watch_buffer_t wb;
99 memset(&wb, 0, sizeof(wb));
102 ASSERT_TRUE(check_for_empty(&wb, client));
108 ASSERT_TRUE(check_for_event(&wb, client, "foo", fuchsia_io_WATCH_EVENT_ADDED));
112 ASSERT_TRUE(check_for_event(&wb, client, "bar", fuchsia_io_WATCH_EVENT_ADDED));
116 ASSERT_TRUE(check_for_event(&wb, client, "blat", fuchsia_io_WATCH_EVENT_ADDED));
123 ASSERT_TRUE(check_for_empty(&wb, client));
162 watch_buffer_t wb;
163 memset(&wb, 0, sizeof(wb));
166 ASSERT_TRUE(check_for_event(&wb, client, ".", fuchsia_io_WATCH_EVENT_EXISTING));
167 ASSERT_TRUE(check_for_event(&wb, client, "foo", fuchsia_io_WATCH_EVENT_EXISTING));
168 ASSERT_TRUE(check_for_event(&wb, client, "bar", fuchsia_io_WATCH_EVENT_EXISTING));
169 ASSERT_TRUE(check_for_event(&wb, client, "", fuchsia_io_WATCH_EVENT_IDLE));
170 ASSERT_TRUE(check_for_empty(&wb, client));
177 ASSERT_TRUE(check_for_event(&wb, client, "baz", fuchsia_io_WATCH_EVENT_ADDED));
178 ASSERT_TRUE(check_for_empty(&wb, client));
195 ASSERT_TRUE(check_for_empty(&wb, client));
203 ASSERT_TRUE(check_for_empty(&wb, client));
234 watch_buffer_t wb;
235 memset(&wb, 0, sizeof(wb));
237 ASSERT_TRUE(check_for_empty(&wb, client));
243 ASSERT_TRUE(check_for_event(&wb, client, "foo", fuchsia_io_WATCH_EVENT_ADDED));
244 ASSERT_TRUE(check_for_empty(&wb, client));
248 ASSERT_TRUE(check_for_event(&wb, client, "foo", fuchsia_io_WATCH_EVENT_REMOVED));
249 ASSERT_TRUE(check_for_event(&wb, client, "bar", fuchsia_io_WATCH_EVENT_ADDED));
250 ASSERT_TRUE(check_for_empty(&wb, client));
253 ASSERT_TRUE(check_for_event(&wb, client, "bar", fuchsia_io_WATCH_EVENT_REMOVED));
254 ASSERT_TRUE(check_for_empty(&wb, client));