From e1910bec0173342c4b2209f27648de581d757140 Mon Sep 17 00:00:00 2001 From: premalathak12 Date: Mon, 25 Sep 2023 14:25:10 +0530 Subject: [PATCH] emulator changes readded --- verification/verification_test.go | 32 +++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/verification/verification_test.go b/verification/verification_test.go index 50837087..c0db9fd7 100644 --- a/verification/verification_test.go +++ b/verification/verification_test.go @@ -5,6 +5,7 @@ package verification import ( "errors" "flag" + "log" "os" "reflect" "testing" @@ -22,13 +23,13 @@ var testTargetType string // This will be called before running tests, and it assigns the socket path based on command line flag. func TestMain(m *testing.M) { - testTarget := flag.String("target", "simulator", "socket type - emulator") + testTarget := flag.String("target", "emulator", "socket type - simulator") flag.Parse() testTargetType = *testTarget if testTargetType == SIMULATOR { target_exe = flag.String("sim", "../simulator/target/debug/simulator", "path to simulator executable") } else if testTargetType == EMULATOR { - target_exe = flag.String("emu", "../simulator/target/debug/emulator", "path to emulator executable") + target_exe = flag.String("emu", "../server/example", "path to emulator executable") } exitVal := m.Run() @@ -98,16 +99,35 @@ func GetTestTarget(support_needed []string) (TestDPEInstance, error) { // Get the emulator target func GetEmulatorTarget(support_needed []string) (TestDPEInstance, error) { + // TODO : Get the supported modes from emulator and then check. + var instance TestDPEInstance = &DpeEmulator{exe_path: *target_exe} + if instance.HasPowerControl() { + err := instance.PowerOn() + if err != nil { + log.Fatal(err) + } + defer instance.PowerOff() + } + + client, err := NewClient384(instance) + if err != nil { + return nil, errors.New("Error in getting client") + } - /*value := reflect.ValueOf(DpeEmulator{}.supports) + rsp, err := client.GetProfile() + if err != nil { + return nil, errors.New("Unable to get profile") + } + + support := Support{} + + value := reflect.ValueOf(support.ToSupport(rsp.Flags)) for i := 0; i < len(support_needed); i++ { support := reflect.Indirect(value).FieldByName(support_needed[i]) if !support.Bool() { return nil, errors.New("Error in creating dpe instances - supported feature is not enabled in emulator") } - }*/ - // TODO : Get the supported modes from emulator and then check. - var instance TestDPEInstance = &DpeEmulator{exe_path: *target_exe} + } return instance, nil }