Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 1 | package main |
| 2 | |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 3 | import ( |
| 4 | "fmt" |
| 5 | |
| 6 | . "github.com/onsi/ginkgo/v2" |
| 7 | ) |
| 8 | |
| 9 | func init() { |
| 10 | registerTapTests(LinuxIperfTest) |
| 11 | } |
| 12 | |
| 13 | func LinuxIperfTest(s *TapSuite) { |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 14 | clnCh := make(chan error) |
| 15 | stopServerCh := make(chan struct{}) |
| 16 | srvCh := make(chan error, 1) |
Maros Ondrejicka | 8753180 | 2022-12-19 20:35:27 +0100 | [diff] [blame] | 17 | clnRes := make(chan string, 1) |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 18 | defer func() { |
| 19 | stopServerCh <- struct{}{} |
| 20 | }() |
| 21 | |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 22 | go func() { |
| 23 | defer GinkgoRecover() |
| 24 | s.startServerApp(srvCh, stopServerCh, nil) |
| 25 | }() |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 26 | err := <-srvCh |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 27 | s.assertNil(err, fmt.Sprint(err)) |
Maros Ondrejicka | 8753180 | 2022-12-19 20:35:27 +0100 | [diff] [blame] | 28 | s.log("server running") |
Maros Ondrejicka | 2908f8c | 2023-02-02 08:58:04 +0100 | [diff] [blame] | 29 | |
adrianvillin | 28bd8f0 | 2024-02-13 06:00:02 -0500 | [diff] [blame] | 30 | ipAddress := s.getInterfaceByName(tapInterfaceName).ip4AddressString() |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 31 | go func() { |
| 32 | defer GinkgoRecover() |
| 33 | s.startClientApp(ipAddress, nil, clnCh, clnRes) |
| 34 | }() |
Maros Ondrejicka | 8753180 | 2022-12-19 20:35:27 +0100 | [diff] [blame] | 35 | s.log("client running") |
Filip Tehlar | f3ee2b6 | 2023-01-09 12:07:09 +0100 | [diff] [blame] | 36 | s.log(<-clnRes) |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 37 | err = <-clnCh |
adrianvillin | 7c67547 | 2024-02-12 02:44:53 -0500 | [diff] [blame] | 38 | s.assertNil(err, "err: '%s', ip: '%s'", err, ipAddress) |
Maros Ondrejicka | 8753180 | 2022-12-19 20:35:27 +0100 | [diff] [blame] | 39 | s.log("Test completed") |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 40 | } |