From b373b76f58e59075ff17f47cd0d3cd259c0c6d3e Mon Sep 17 00:00:00 2001 From: "CTFang@WireLab" Date: Thu, 28 Mar 2024 04:21:29 +0000 Subject: [PATCH] fix: update typo and add args for fuzz test --- Makefile | 2 +- fuzz/ie_fuzz_test.go | 33 +++++++-------------------------- 2 files changed, 8 insertions(+), 27 deletions(-) diff --git a/Makefile b/Makefile index 1d08297..fdf887c 100644 --- a/Makefile +++ b/Makefile @@ -27,7 +27,7 @@ golint: mkdir -p $(CURDIR)/.coverage # -run flag ensures that the fuzz test won't be run -# because the fuzz test needs to run with the running UPF +# because the fuzz test needs a UPF to run test: .coverage go test -race -coverprofile=.coverage/coverage-unit.txt -covermode=atomic -run=^Test -v ./... diff --git a/fuzz/ie_fuzz_test.go b/fuzz/ie_fuzz_test.go index 561329b..a9b03f9 100644 --- a/fuzz/ie_fuzz_test.go +++ b/fuzz/ie_fuzz_test.go @@ -5,6 +5,7 @@ package fuzz import ( "crypto/rand" + "flag" "math/big" "testing" "time" @@ -28,31 +29,11 @@ func getRand(n int) int { return int(res.Int64()) } -// Example of a basic function test -// func TestBasicFunction(t *testing.T) { -// sim := export.NewPfcpSimCfg("eth0", "192.168.0.5", "127.0.0.8") -// err := sim.InitPFCPSim() -// if err != nil { -// require.NoError(t, err, "InitPFCPSim failed") -// } -// err = sim.Associate() -// if err != nil { -// require.NoError(t, err, "Associate failed") -// } -// defer func() { -// err = sim.TerminatePFCPSim() -// require.NoError(t, err) -// }() -// err = sim.CreateSession(2, -// session.PdrNoFuzz, -// session.QerNoFuzz, -// session.FarNoFuzz, -// session.UrrNoFuzz, -// uint(0)) -// if err != nil { -// require.NoError(t, err, "CreateSession failed") -// } -// } +var ( + iface = flag.String("iface", "eth0", "the interface name you used to establish the connection with UPF.") + upfN3 = flag.String("upfN3", "192.168.0.5", "the N3 interface address of the UPF") + upfN4 = flag.String("upfN4", "127.0.0.8", "the N4 interface address of the UPF") +) func Fuzz(f *testing.F) { var testcases []uint @@ -69,7 +50,7 @@ func Fuzz(f *testing.F) { f.Fuzz(func(t *testing.T, input uint) { time.Sleep(5 * time.Second) - sim := export.NewPfcpSimCfg("eth0", "192.168.0.5", "127.0.0.8") + sim := export.NewPfcpSimCfg(*iface, *upfN3, *upfN4) err := sim.InitPFCPSim() if err != nil {