Rev 4389 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 4389 | Rev 4691 | ||
|---|---|---|---|
| Line 26... | Line 26... | ||
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | */ |
27 | */ |
| 28 | 28 | ||
| 29 | #include <stdio.h> |
29 | #include <stdio.h> |
| 30 | #include <stdlib.h> |
30 | #include <stdlib.h> |
| 31 | #include <console.h> |
- | |
| 32 | #include <sys/time.h> |
31 | #include <sys/time.h> |
| - | 32 | #include <ipc/ns.h> |
|
| - | 33 | #include <async.h> |
|
| - | 34 | #include <errno.h> |
|
| 33 | #include "../tester.h" |
35 | #include "../tester.h" |
| 34 | 36 | ||
| 35 | #define DURATION_SECS 10 |
37 | #define DURATION_SECS 10 |
| 36 | #define COUNT_GRANULARITY 100 |
38 | #define COUNT_GRANULARITY 100 |
| 37 | 39 | ||
| 38 | char * test_ping_pong(bool quiet) |
40 | char *test_ping_pong(void) |
| 39 | { |
41 | { |
| 40 | int i; |
- | |
| 41 | int w, h; |
- | |
| 42 | struct timeval start, now; |
- | |
| 43 | long count; |
- | |
| 44 | - | ||
| 45 | printf("Pinging console server for %d seconds...\n", DURATION_SECS); |
42 | TPRINTF("Pinging ns server for %d seconds...", DURATION_SECS); |
| 46 | 43 | ||
| - | 44 | struct timeval start; |
|
| 47 | if (gettimeofday(&start, NULL) != 0) |
45 | if (gettimeofday(&start, NULL) != 0) { |
| - | 46 | TPRINTF("\n"); |
|
| 48 | return "Failed getting the time."; |
47 | return "Failed getting the time"; |
| - | 48 | } |
|
| 49 | 49 | ||
| 50 | count = 0; |
50 | uint64_t count = 0; |
| 51 | - | ||
| 52 | while (true) { |
51 | while (true) { |
| - | 52 | struct timeval now; |
|
| 53 | if (gettimeofday(&now, NULL) != 0) |
53 | if (gettimeofday(&now, NULL) != 0) { |
| - | 54 | TPRINTF("\n"); |
|
| 54 | return "Failed getting the time."; |
55 | return "Failed getting the time"; |
| - | 56 | } |
|
| 55 | 57 | ||
| 56 | if (tv_sub(&now, &start) >= DURATION_SECS * 1000000L) |
58 | if (tv_sub(&now, &start) >= DURATION_SECS * 1000000L) |
| 57 | break; |
59 | break; |
| 58 | 60 | ||
| - | 61 | size_t i; |
|
| 59 | for (i = 0; i < COUNT_GRANULARITY; i++) |
62 | for (i = 0; i < COUNT_GRANULARITY; i++) { |
| - | 63 | int retval = async_req_0_0(PHONE_NS, NS_PING); |
|
| - | 64 | ||
| 60 | console_get_size(&w, &h); |
65 | if (retval != EOK) { |
| - | 66 | TPRINTF("\n"); |
|
| - | 67 | return "Failed to send ping message"; |
|
| - | 68 | } |
|
| - | 69 | } |
|
| - | 70 | ||
| 61 | count += COUNT_GRANULARITY; |
71 | count += COUNT_GRANULARITY; |
| 62 | } |
72 | } |
| 63 | 73 | ||
| 64 | printf("Completed %ld round trips in %d seconds, %ld RT/s.\n", count, |
74 | TPRINTF("OK\nCompleted %llu round trips in %u seconds, %llu rt/s.\n", |
| 65 | DURATION_SECS, count / DURATION_SECS); |
75 | count, DURATION_SECS, count / DURATION_SECS); |
| 66 | 76 | ||
| 67 | return NULL; |
77 | return NULL; |
| 68 | } |
78 | } |