Rev 4537 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4537 | Rev 4668 | ||
---|---|---|---|
Line 35... | Line 35... | ||
35 | #include "../tester.h" |
35 | #include "../tester.h" |
36 | 36 | ||
37 | #define DURATION_SECS 10 |
37 | #define DURATION_SECS 10 |
38 | #define COUNT_GRANULARITY 100 |
38 | #define COUNT_GRANULARITY 100 |
39 | 39 | ||
40 | char *test_ping_pong(bool quiet) |
40 | char *test_ping_pong(void) |
41 | { |
41 | { |
42 | printf("Pinging ns server for %d seconds...\n", DURATION_SECS); |
42 | TPRINTF("Pinging ns server for %d seconds...", DURATION_SECS); |
43 | 43 | ||
44 | struct timeval start; |
44 | struct timeval start; |
45 | if (gettimeofday(&start, NULL) != 0) |
45 | if (gettimeofday(&start, NULL) != 0) { |
- | 46 | TPRINTF("\n"); |
|
46 | return "Failed getting the time."; |
47 | return "Failed getting the time"; |
- | 48 | } |
|
47 | 49 | ||
48 | uint64_t count = 0; |
50 | uint64_t count = 0; |
49 | - | ||
50 | while (true) { |
51 | while (true) { |
51 | struct timeval now; |
52 | struct timeval now; |
52 | if (gettimeofday(&now, NULL) != 0) |
53 | if (gettimeofday(&now, NULL) != 0) { |
- | 54 | TPRINTF("\n"); |
|
53 | return "Failed getting the time."; |
55 | return "Failed getting the time"; |
- | 56 | } |
|
54 | 57 | ||
55 | if (tv_sub(&now, &start) >= DURATION_SECS * 1000000L) |
58 | if (tv_sub(&now, &start) >= DURATION_SECS * 1000000L) |
56 | break; |
59 | break; |
57 | 60 | ||
58 | size_t i; |
61 | size_t i; |
59 | for (i = 0; i < COUNT_GRANULARITY; i++) { |
62 | for (i = 0; i < COUNT_GRANULARITY; i++) { |
60 | int retval = async_req_0_0(PHONE_NS, NS_PING); |
63 | int retval = async_req_0_0(PHONE_NS, NS_PING); |
61 | 64 | ||
62 | if (retval != EOK) |
65 | if (retval != EOK) { |
- | 66 | TPRINTF("\n"); |
|
63 | return "Failed to send ping message."; |
67 | return "Failed to send ping message"; |
- | 68 | } |
|
64 | } |
69 | } |
65 | 70 | ||
66 | count += COUNT_GRANULARITY; |
71 | count += COUNT_GRANULARITY; |
67 | } |
72 | } |
68 | 73 | ||
69 | printf("Completed %lu round trips in %u seconds, %lu RT/s.\n", |
74 | TPRINTF("OK\nCompleted %llu round trips in %u seconds, %llu rt/s.\n", |
70 | count, DURATION_SECS, count / DURATION_SECS); |
75 | count, DURATION_SECS, count / DURATION_SECS); |
71 | 76 | ||
72 | return NULL; |
77 | return NULL; |
73 | } |
78 | } |