blob: e323f7fb7217cf8417fa461af5220cf3e3df3697 [file] [log] [blame]
Filip Tehlar229f5fc2022-08-09 14:44:47 +00001package main
2
Adrian Villincee15aa2024-03-14 11:42:55 -04003import (
4 "fmt"
5
6 . "github.com/onsi/ginkgo/v2"
7)
8
9func init() {
10 registerTapTests(LinuxIperfTest)
11}
12
13func LinuxIperfTest(s *TapSuite) {
Filip Tehlar229f5fc2022-08-09 14:44:47 +000014 clnCh := make(chan error)
15 stopServerCh := make(chan struct{})
16 srvCh := make(chan error, 1)
Maros Ondrejicka87531802022-12-19 20:35:27 +010017 clnRes := make(chan string, 1)
Filip Tehlar229f5fc2022-08-09 14:44:47 +000018 defer func() {
19 stopServerCh <- struct{}{}
20 }()
21
Adrian Villincee15aa2024-03-14 11:42:55 -040022 go func() {
23 defer GinkgoRecover()
24 s.startServerApp(srvCh, stopServerCh, nil)
25 }()
Filip Tehlar229f5fc2022-08-09 14:44:47 +000026 err := <-srvCh
Adrian Villincee15aa2024-03-14 11:42:55 -040027 s.assertNil(err, fmt.Sprint(err))
Maros Ondrejicka87531802022-12-19 20:35:27 +010028 s.log("server running")
Maros Ondrejicka2908f8c2023-02-02 08:58:04 +010029
adrianvillin28bd8f02024-02-13 06:00:02 -050030 ipAddress := s.getInterfaceByName(tapInterfaceName).ip4AddressString()
Adrian Villincee15aa2024-03-14 11:42:55 -040031 go func() {
32 defer GinkgoRecover()
33 s.startClientApp(ipAddress, nil, clnCh, clnRes)
34 }()
Maros Ondrejicka87531802022-12-19 20:35:27 +010035 s.log("client running")
Filip Tehlarf3ee2b62023-01-09 12:07:09 +010036 s.log(<-clnRes)
Filip Tehlar229f5fc2022-08-09 14:44:47 +000037 err = <-clnCh
adrianvillin7c675472024-02-12 02:44:53 -050038 s.assertNil(err, "err: '%s', ip: '%s'", err, ipAddress)
Maros Ondrejicka87531802022-12-19 20:35:27 +010039 s.log("Test completed")
Filip Tehlar229f5fc2022-08-09 14:44:47 +000040}