diff options
author | sotech117 <michael_foiani@brown.edu> | 2023-10-09 12:47:09 -0400 |
---|---|---|
committer | sotech117 <michael_foiani@brown.edu> | 2023-10-09 12:47:09 -0400 |
commit | a00f93e745b588d8bb55a7af7b8b94a2ff5adca0 (patch) | |
tree | 7b5adfe38e80ea93967114fd6fb0cf08ccd144f5 /pkg/ipstack/ipstack_test.go | |
parent | 05b4acd8843805230484bb2a35846fe06566084f (diff) |
simply system of threads that abstracts the Link layer
Diffstat (limited to 'pkg/ipstack/ipstack_test.go')
-rw-r--r-- | pkg/ipstack/ipstack_test.go | 45 |
1 files changed, 45 insertions, 0 deletions
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() }) +} |