From a00f93e745b588d8bb55a7af7b8b94a2ff5adca0 Mon Sep 17 00:00:00 2001 From: sotech117 Date: Mon, 9 Oct 2023 12:47:09 -0400 Subject: simply system of threads that abstracts the Link layer --- pkg/ipstack/ipstack_test.go | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'pkg/ipstack/ipstack_test.go') diff --git a/pkg/ipstack/ipstack_test.go b/pkg/ipstack/ipstack_test.go index d5b755a..97c4947 100644 --- a/pkg/ipstack/ipstack_test.go +++ b/pkg/ipstack/ipstack_test.go @@ -53,3 +53,48 @@ func TestInterfaceUpThenDown(t *testing.T) { fmt.Println("TestInterfaceUpThenDown successful") t.Cleanup(func() { CleanUp() }) } + +func TestInterfaceUpThenDownTwice(t *testing.T) { + lnxFilePath := "../../doc-example/r2.lnx" + err := Initialize(lnxFilePath) + if err != nil { + t.Error(err) + } + + iface, err := GetInterfaceByName("if0") + if err != nil { + t.Error(err) + } + + InterfaceUp(iface) + if iface.State == false { + t.Error("iface state should be true") + } + + fmt.Printf("Interfaces:\n%s\n", SprintInterfaces()) + + time.Sleep(5 * time.Millisecond) // allow time to print + + InterfaceDown(iface) + if iface.State == true { + t.Error("iface state should be false") + } + + InterfaceUp(iface) + if iface.State == false { + t.Error("iface state should be true") + } + time.Sleep(3 * time.Millisecond) // allow time to print + + InterfaceDown(iface) + if iface.State == true { + t.Error("iface state should be false") + } + + time.Sleep(5 * time.Millisecond) // allow time to print + + fmt.Printf("Interfaces:\n%s\n", SprintInterfaces()) + + fmt.Println("TestInterfaceUpThenDownTwice successful") + t.Cleanup(func() { CleanUp() }) +} -- cgit v1.2.3-70-g09d2