From 8b84b5cac636d639040fc9a7da485263ffbc9a09 Mon Sep 17 00:00:00 2001 From: Clément Bénier Date: Thu, 9 Aug 2018 16:28:31 +0200 Subject: test exec: add test for exec MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I505496ca3a8641c401b802faea7a467986a819c9 Signed-off-by: Clément Bénier --- test/exec_test.go | 113 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 test/exec_test.go (limited to 'test/exec_test.go') diff --git a/test/exec_test.go b/test/exec_test.go new file mode 100644 index 0000000..8fb6519 --- /dev/null +++ b/test/exec_test.go @@ -0,0 +1,113 @@ +/* + * Copyright (C) 2017-2018 "IoT.bzh" + * Author Clément Bénier + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package xdsservertest + +import ( + "log" + "os" + "path" + "testing" + "time" + + "gerrit.automotivelinux.org/gerrit/src/xds/xds-server/lib/xsapiv1" + git "github.com/libgit2/git2go" + "github.com/stretchr/testify/assert" +) + +func TestExec(t *testing.T) { + cloneRepo := "https://github.com/iotbzh/helloworld-service.git" + cloneDir := path.Join(os.Getenv(envRootCfgDir), "testExec") + t.Logf("Cloning repo %v in %v\n...\n", cloneRepo, cloneDir) + var cloneOptions git.CloneOptions + repository, err := git.Clone(cloneRepo, cloneDir, &cloneOptions) + if err != nil { + t.Fatal(err) + } + + repository.Submodules.Foreach(func(sub *git.Submodule, name string) int { + sub.Init(true) + err := sub.Update(true, &git.SubmoduleUpdateOptions{ + &git.CheckoutOpts{ + Strategy: git.CheckoutForce | git.CheckoutUpdateSubmodules, + }, + &git.FetchOptions{}, + }) + if err != nil { + log.Fatal(err) + } + return 0 + + }) + + t.Logf("repo cloned\n") + + var cfgArray []xsapiv1.FolderConfig + assert.Nil(t, HTTPCli.Get("/folders", &cfgArray)) + assert.Equal(t, len(cfgArray), 0) + + fPrj := xsapiv1.FolderConfig{ + Label: "testproject", + ClientPath: cloneDir, + Type: xsapiv1.TypePathMap, + ClientData: "clientdatatest", + DataPathMap: xsapiv1.PathMapConfig{ + ServerPath: cloneDir, + }, + } + var cfg xsapiv1.FolderConfig + assert.Nil(t, HTTPCli.Post("/folders", fPrj, &cfg)) + assert.NotNil(t, cfg) + _, err = NewIoSocketClient(prefixURL, HTTPCli.GetClientID()) + if err != nil { + t.Fatal(err) + } + + cmd := "export PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig/" + cmd = cmd + " && " + cmd = cmd + "cd " + fPrj.ClientPath + cmd = cmd + " && " + cmd = cmd + "mkdir -p build" + cmd = cmd + " && " + cmd = cmd + "cd build" + cmd = cmd + " && " + cmd = cmd + "cmake .." + + exec := xsapiv1.ExecArgs{ + ID: cfg.ID, + Cmd: cmd, + } + var execRes xsapiv1.ExecArgs + assert.Nil(t, HTTPCli.Post("/exec", exec, &execRes)) + time.Sleep(3 * time.Second) //maybe waiting for an event would be better + + cmd = "export PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig/" + cmd = cmd + "&&" + cmd = cmd + "cd " + fPrj.ClientPath + cmd = cmd + "&&" + cmd = cmd + "cd build" + cmd = cmd + "&&" + cmd = cmd + "make" + exec.Cmd = cmd + assert.Nil(t, HTTPCli.Post("/exec", exec, &execRes)) + time.Sleep(3 * time.Second) //maybe waiting for an event would be better + + /*check afb-helloworld.so exists*/ + _, err = os.Stat(path.Join(fPrj.ClientPath, "build/helloworld-afb/afb-helloworld.so")) + assert.Nil(t, err) + + assert.Nil(t, HTTPCli.Delete("/folders/"+cfg.ID, &cfg)) +} -- cgit 1.2.3-korg From e0e1d75c08ff6187acabca74261ebeb0e0893ede Mon Sep 17 00:00:00 2001 From: Clément Bénier Date: Tue, 14 Aug 2018 16:29:07 +0200 Subject: tests: better handle websocket client MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Iffc7370c52457e6d90e88e30c95b37ae3c60bce3 Signed-off-by: Clément Bénier --- test/exec_test.go | 4 --- test/sdks_test.go | 83 ++++++++------------------------------------------ test/target_test.go | 7 ++--- test/xdsserver_test.go | 51 +++++++++++++++++++++++++++++++ 4 files changed, 66 insertions(+), 79 deletions(-) (limited to 'test/exec_test.go') diff --git a/test/exec_test.go b/test/exec_test.go index 8fb6519..abe23b5 100644 --- a/test/exec_test.go +++ b/test/exec_test.go @@ -71,10 +71,6 @@ func TestExec(t *testing.T) { var cfg xsapiv1.FolderConfig assert.Nil(t, HTTPCli.Post("/folders", fPrj, &cfg)) assert.NotNil(t, cfg) - _, err = NewIoSocketClient(prefixURL, HTTPCli.GetClientID()) - if err != nil { - t.Fatal(err) - } cmd := "export PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig/" cmd = cmd + " && " diff --git a/test/sdks_test.go b/test/sdks_test.go index 51f1d95..9c3fc7e 100644 --- a/test/sdks_test.go +++ b/test/sdks_test.go @@ -17,82 +17,25 @@ package xdsservertest import ( - "fmt" - "log" "os" "path" "regexp" - "sync" "testing" "time" "gerrit.automotivelinux.org/gerrit/src/xds/xds-server/lib/xsapiv1" - socketio_client "github.com/sebd71/go-socket.io-client" "github.com/stretchr/testify/assert" ) -var ch chan xsapiv1.SDK - -// Disconnection Channel used to notify XDS Server disconnection -//type Disconnection struct { -// error string -// code int -// svrConf ServerCfg -//} - -// IOSockClient . -type IOSockClient struct { - URL string - Conn *socketio_client.Client - Options *socketio_client.Options - EmitMutex *sync.Mutex - Connected bool - //ServerDiscoChan chan Disconnection - EscapeKeys []byte -} - -func NewIoSocketClient(url, clientID string) (*IOSockClient, error) { - - var err error - - sCli := &IOSockClient{ - URL: url, - EmitMutex: &sync.Mutex{}, - Options: &socketio_client.Options{ - Transport: "websocket", - Header: make(map[string][]string), - }, - //ServerDiscoChan: make(chan Disconnection, 1), - } - sCli.Options.Header["XDS-SID"] = []string{clientID} - - sCli.Conn, err = socketio_client.NewClient(url, sCli.Options) - if err != nil { - return nil, fmt.Errorf("IO.socket connection error: " + err.Error()) - } - - sCli.Conn.On("connection", func() { - sCli.Connected = true - }) - - sCli.Conn.On("disconnection", func(err error) { - log.Printf("WS disconnection event with err: %v\n", err) - sCli.Connected = false - }) +func ConnectSDKStateChange(t *testing.T, sCli *IOSockClient, channel chan xsapiv1.SDK) { sCli.Conn.On(xsapiv1.EVTSDKStateChange, func(e xsapiv1.EventMsg) { sdk, _ := e.DecodeSDKEvent() - ch <- sdk + channel <- sdk }) args := xsapiv1.EventRegisterArgs{Name: xsapiv1.EVTSDKStateChange} - if err := HTTPCli.Post("/events/register", args, nil); err != nil { - return sCli, err - } - - //sCli.Conn.On(xsapiv1.) - - return sCli, nil + assert.Nil(t, HTTPCli.Post("/events/register", args, nil)) } func TestSdks(t *testing.T) { @@ -101,12 +44,9 @@ func TestSdks(t *testing.T) { _, err := os.Stat(path.Join(sdkDir, "sdks_latest.json")) assert.Nil(t, err) t.Logf("Connect websocket with url=%v clientId=%v\n", prefixURL, HTTPCli.GetClientID()) - _, err = NewIoSocketClient(prefixURL, HTTPCli.GetClientID()) - if err != nil { - t.Fatal(err) - } - ch = make(chan xsapiv1.SDK) + chSdks := make(chan xsapiv1.SDK) + ConnectSDKStateChange(t, sCli, chSdks) for i := 0; i < len(sdkArray); i++ { re := regexp.MustCompile("^[0-9a-z]+-[0-9a-z]+-[0-9a-z]+-[0-9a-z]+-[0-9a-z]+$") @@ -124,18 +64,18 @@ func TestSdks(t *testing.T) { assert.Nil(t, HTTPCli.Post("/sdks/abortinstall", sdk, &sdkRes)) assert.Equal(t, sdkRes.Status, "Not Installed") time.Sleep(1 * time.Millisecond) - sdkFromEvent := <-ch + sdkFromEvent := <-chSdks assert.Equal(t, sdkRes.ID, sdkFromEvent.ID) assert.Equal(t, sdkRes.Status, sdkFromEvent.Status) } } -func installFakeSdk(t *testing.T, sdkInstall xsapiv1.SDKInstallArgs) xsapiv1.SDK { +func installFakeSdk(t *testing.T, sdkInstall xsapiv1.SDKInstallArgs, chSdks chan xsapiv1.SDK) xsapiv1.SDK { var sdkRes xsapiv1.SDK assert.Nil(t, HTTPCli.Post("/sdks", sdkInstall, &sdkRes)) assert.Equal(t, sdkRes.Status, "Installing") /*waiting for SDKStateChange event from channel*/ - sdkFromEvent := <-ch + sdkFromEvent := <-chSdks t.Log(sdkFromEvent) assert.Equal(t, sdkRes.ID, sdkFromEvent.ID) assert.Equal(t, "Installed", sdkFromEvent.Status) @@ -148,11 +88,14 @@ func TestInstallFakeSdk(t *testing.T) { Filename: sdkFileName, Force: false, } - installFakeSdk(t, sdk) + + chSdks := make(chan xsapiv1.SDK) + ConnectSDKStateChange(t, sCli, chSdks) + installFakeSdk(t, sdk, chSdks) var sdkRes xsapiv1.SDK assert.NotNil(t, HTTPCli.Post("/sdks", sdk, &sdkRes)) sdk.Force = true - //installFakeSdk(t, sdk) + //installFakeSdk(t, sdk, chSdks) } func TestSdksError(t *testing.T) { diff --git a/test/target_test.go b/test/target_test.go index 696c8fc..1cfaa94 100644 --- a/test/target_test.go +++ b/test/target_test.go @@ -70,10 +70,7 @@ func TestTarget(t *testing.T) { chTerm := make(chan xsapiv1.TerminalOutMsg) defer close(chTerm) - sCli, err := NewIoSocketClient(prefixURL, HTTPCli.GetClientID()) - if err != nil { - t.Fatal(err) - } + sCli.Conn.On(xsapiv1.TerminalOutEvent, func(ev xsapiv1.TerminalOutMsg) { chTerm <- ev }) @@ -106,7 +103,7 @@ func TestTarget(t *testing.T) { flushChannelTerm(chTerm, 50) /*check that toto file is created*/ - _, err = os.Stat(totoFileCurrent) + _, err := os.Stat(totoFileCurrent) assert.Nil(t, err) data = []byte("cat " + totoFileCurrent + "\n") diff --git a/test/xdsserver_test.go b/test/xdsserver_test.go index 76c54ea..585ad50 100644 --- a/test/xdsserver_test.go +++ b/test/xdsserver_test.go @@ -17,22 +17,37 @@ package xdsservertest import ( + "fmt" "io" "log" "os" "os/exec" "path" + "sync" "testing" "time" common "gerrit.automotivelinux.org/gerrit/src/xds/xds-common.git/golib" "gerrit.automotivelinux.org/gerrit/src/xds/xds-server/lib/xsapiv1" + socketio_client "github.com/sebd71/go-socket.io-client" ) +// IOSockClient +type IOSockClient struct { + URL string + Conn *socketio_client.Client + Options *socketio_client.Options + EmitMutex *sync.Mutex + Connected bool + //ServerDiscoChan chan Disconnection + EscapeKeys []byte +} + //global client var HTTPCli *common.HTTPClient var logDir string var sdkDir string +var sCli *IOSockClient func Copy(src, dst string) error { in, err := os.Open(src) @@ -136,6 +151,37 @@ func getHTTPClient(lvl int) (*common.HTTPClient, *os.File) { return cli, file } +func NewIoSocketClient(url, clientID string) (*IOSockClient, error) { + + var err error + + sCli := &IOSockClient{ + URL: url, + EmitMutex: &sync.Mutex{}, + Options: &socketio_client.Options{ + Transport: "websocket", + Header: make(map[string][]string), + }, + //ServerDiscoChan: make(chan Disconnection, 1), + } + sCli.Options.Header["XDS-SID"] = []string{clientID} + + sCli.Conn, err = socketio_client.NewClient(url, sCli.Options) + if err != nil { + return nil, fmt.Errorf("IO.socket connection error: " + err.Error()) + } + + sCli.Conn.On("connection", func() { + sCli.Connected = true + }) + + sCli.Conn.On("disconnection", func(err error) { + log.Printf("WS disconnection event with err: %v\n", err) + sCli.Connected = false + }) + + return sCli, nil +} func TestMain(m *testing.M) { launchProcess := true log.Printf("TestMain: launchProcess is %v", launchProcess) @@ -159,6 +205,11 @@ func TestMain(m *testing.M) { var fileHTTPClient *os.File HTTPCli, fileHTTPClient = getHTTPClient(lvl) defer fileHTTPClient.Close() + var err error + sCli, err = NewIoSocketClient(prefixURL, HTTPCli.GetClientID()) + if err != nil { + log.Fatal(err) + } log.Printf("HTTPCli id is %v", HTTPCli.GetClientID()) -- cgit 1.2.3-korg From 330d6849a51ea6b47d90e9cd6f6ee43a7c2fb10e Mon Sep 17 00:00:00 2001 From: Clément Bénier Date: Tue, 14 Aug 2018 16:44:47 +0200 Subject: test exec: waiting for events and timeout while building MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I4caf0dd3e59f920f602131638c58e11beb9f3e08 Signed-off-by: Clément Bénier --- test/exec_test.go | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'test/exec_test.go') diff --git a/test/exec_test.go b/test/exec_test.go index abe23b5..5d4c106 100644 --- a/test/exec_test.go +++ b/test/exec_test.go @@ -28,6 +28,17 @@ import ( "github.com/stretchr/testify/assert" ) +/*flush channel with timeout*/ +func flushChannelExec(channel chan xsapiv1.ExecOutMsg, ms time.Duration) { + timeoutB := false + for !timeoutB { + select { + case <-channel: + case <-time.After(ms * time.Millisecond): + timeoutB = true + } + } +} func TestExec(t *testing.T) { cloneRepo := "https://github.com/iotbzh/helloworld-service.git" cloneDir := path.Join(os.Getenv(envRootCfgDir), "testExec") @@ -72,6 +83,12 @@ func TestExec(t *testing.T) { assert.Nil(t, HTTPCli.Post("/folders", fPrj, &cfg)) assert.NotNil(t, cfg) + chExec := make(chan xsapiv1.ExecOutMsg) + defer close(chExec) + sCli.Conn.On(xsapiv1.ExecOutEvent, func(ev xsapiv1.ExecOutMsg) { + chExec <- ev + }) + cmd := "export PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig/" cmd = cmd + " && " cmd = cmd + "cd " + fPrj.ClientPath @@ -88,7 +105,7 @@ func TestExec(t *testing.T) { } var execRes xsapiv1.ExecArgs assert.Nil(t, HTTPCli.Post("/exec", exec, &execRes)) - time.Sleep(3 * time.Second) //maybe waiting for an event would be better + flushChannelExec(chExec, 1000) cmd = "export PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig/" cmd = cmd + "&&" @@ -99,7 +116,7 @@ func TestExec(t *testing.T) { cmd = cmd + "make" exec.Cmd = cmd assert.Nil(t, HTTPCli.Post("/exec", exec, &execRes)) - time.Sleep(3 * time.Second) //maybe waiting for an event would be better + flushChannelExec(chExec, 1000) /*check afb-helloworld.so exists*/ _, err = os.Stat(path.Join(fPrj.ClientPath, "build/helloworld-afb/afb-helloworld.so")) -- cgit 1.2.3-korg From cf3266b208d3ba0fb8f172c29725768bbd41d509 Mon Sep 17 00:00:00 2001 From: Clément Bénier Date: Fri, 17 Aug 2018 16:45:30 +0200 Subject: test exec: remove git2go and cloning afb-helloworld MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit replace it by fixtures in test/helloworld and copying repo to XDS_SERVER_ROOT_CFG_DIR and cloning app-templates repo into it Change-Id: I4f3d9cfae0f1b81bd7994e172235b1fbc25fd383 Signed-off-by: Clément Bénier --- glide.yaml | 2 - test/config.go | 1 + test/exec_test.go | 56 +++---- test/fixtures/helloworld/CMakeLists.txt | 3 + test/fixtures/helloworld/conf.d/cmake/config.cmake | 167 +++++++++++++++++++++ test/fixtures/helloworld/helloworld/CMakeLists.txt | 36 +++++ test/fixtures/helloworld/helloworld/helloworld.c | 6 + 7 files changed, 233 insertions(+), 38 deletions(-) create mode 100644 test/fixtures/helloworld/CMakeLists.txt create mode 100644 test/fixtures/helloworld/conf.d/cmake/config.cmake create mode 100644 test/fixtures/helloworld/helloworld/CMakeLists.txt create mode 100644 test/fixtures/helloworld/helloworld/helloworld.c (limited to 'test/exec_test.go') diff --git a/glide.yaml b/glide.yaml index eae47ea..69ee318 100644 --- a/glide.yaml +++ b/glide.yaml @@ -39,5 +39,3 @@ import: - assert - package: github.com/sebd71/go-socket.io-client version: 46defcb47f -- package: github.com/libgit2/git2go - version: v27 diff --git a/test/config.go b/test/config.go index a551d4f..4850919 100644 --- a/test/config.go +++ b/test/config.go @@ -29,4 +29,5 @@ const ( envXdsServerRootCfgDir = "XDS_SERVER_ROOT_CFG_DIR" sdkFileName = "poky-agl-glibc-x86_64-gcc_crosssdk-native_x86_64-toolchain-1.0.2.sh" sdkFile = "fixtures/" + sdkFileName + helloworldFixturesDir = "fixtures/helloworld" ) diff --git a/test/exec_test.go b/test/exec_test.go index 5d4c106..f2d48ce 100644 --- a/test/exec_test.go +++ b/test/exec_test.go @@ -17,17 +17,29 @@ package xdsservertest import ( - "log" + "bytes" "os" + "os/exec" "path" "testing" "time" "gerrit.automotivelinux.org/gerrit/src/xds/xds-server/lib/xsapiv1" - git "github.com/libgit2/git2go" "github.com/stretchr/testify/assert" ) +func InitExec(t *testing.T) string { + helloworldDir := path.Join(os.Getenv(envRootCfgDir), "helloworld") + cmd := exec.Command("cp", "-r", helloworldFixturesDir, helloworldDir) + var out bytes.Buffer + cmd.Stdout = &out + assert.Nil(t, cmd.Run()) + subHelloworldAppTemplateDir := path.Join(helloworldDir, "conf.d", "app-templates") + cmd = exec.Command("git", "clone", "https://gerrit.automotivelinux.org/gerrit/p/apps/app-templates.git", subHelloworldAppTemplateDir) + assert.Nil(t, cmd.Run()) + return helloworldDir +} + /*flush channel with timeout*/ func flushChannelExec(channel chan xsapiv1.ExecOutMsg, ms time.Duration) { timeoutB := false @@ -40,31 +52,7 @@ func flushChannelExec(channel chan xsapiv1.ExecOutMsg, ms time.Duration) { } } func TestExec(t *testing.T) { - cloneRepo := "https://github.com/iotbzh/helloworld-service.git" - cloneDir := path.Join(os.Getenv(envRootCfgDir), "testExec") - t.Logf("Cloning repo %v in %v\n...\n", cloneRepo, cloneDir) - var cloneOptions git.CloneOptions - repository, err := git.Clone(cloneRepo, cloneDir, &cloneOptions) - if err != nil { - t.Fatal(err) - } - - repository.Submodules.Foreach(func(sub *git.Submodule, name string) int { - sub.Init(true) - err := sub.Update(true, &git.SubmoduleUpdateOptions{ - &git.CheckoutOpts{ - Strategy: git.CheckoutForce | git.CheckoutUpdateSubmodules, - }, - &git.FetchOptions{}, - }) - if err != nil { - log.Fatal(err) - } - return 0 - - }) - - t.Logf("repo cloned\n") + helloworldDir := InitExec(t) var cfgArray []xsapiv1.FolderConfig assert.Nil(t, HTTPCli.Get("/folders", &cfgArray)) @@ -72,11 +60,11 @@ func TestExec(t *testing.T) { fPrj := xsapiv1.FolderConfig{ Label: "testproject", - ClientPath: cloneDir, + ClientPath: helloworldDir, Type: xsapiv1.TypePathMap, ClientData: "clientdatatest", DataPathMap: xsapiv1.PathMapConfig{ - ServerPath: cloneDir, + ServerPath: helloworldDir, }, } var cfg xsapiv1.FolderConfig @@ -89,9 +77,7 @@ func TestExec(t *testing.T) { chExec <- ev }) - cmd := "export PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig/" - cmd = cmd + " && " - cmd = cmd + "cd " + fPrj.ClientPath + cmd := "cd " + fPrj.ClientPath cmd = cmd + " && " cmd = cmd + "mkdir -p build" cmd = cmd + " && " @@ -107,9 +93,7 @@ func TestExec(t *testing.T) { assert.Nil(t, HTTPCli.Post("/exec", exec, &execRes)) flushChannelExec(chExec, 1000) - cmd = "export PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig/" - cmd = cmd + "&&" - cmd = cmd + "cd " + fPrj.ClientPath + cmd = "cd " + fPrj.ClientPath cmd = cmd + "&&" cmd = cmd + "cd build" cmd = cmd + "&&" @@ -119,7 +103,7 @@ func TestExec(t *testing.T) { flushChannelExec(chExec, 1000) /*check afb-helloworld.so exists*/ - _, err = os.Stat(path.Join(fPrj.ClientPath, "build/helloworld-afb/afb-helloworld.so")) + _, err := os.Stat(path.Join(fPrj.ClientPath, "build/helloworld/helloworld.so")) assert.Nil(t, err) assert.Nil(t, HTTPCli.Delete("/folders/"+cfg.ID, &cfg)) diff --git a/test/fixtures/helloworld/CMakeLists.txt b/test/fixtures/helloworld/CMakeLists.txt new file mode 100644 index 0000000..f757721 --- /dev/null +++ b/test/fixtures/helloworld/CMakeLists.txt @@ -0,0 +1,3 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 3.3) + +include(${CMAKE_CURRENT_SOURCE_DIR}/conf.d/cmake/config.cmake) diff --git a/test/fixtures/helloworld/conf.d/cmake/config.cmake b/test/fixtures/helloworld/conf.d/cmake/config.cmake new file mode 100644 index 0000000..00b4de1 --- /dev/null +++ b/test/fixtures/helloworld/conf.d/cmake/config.cmake @@ -0,0 +1,167 @@ +########################################################################### +# Copyright 2015, 2016, 2017 IoT.bzh +# +# author: Fulup Ar Foll +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +########################################################################### + +# Project Info +# ------------------ +set(PROJECT_NAME helloworld) +set(PROJECT_VERSION "1.0") +set(PROJECT_PRETTY_NAME "Helloworld") +set(PROJECT_DESCRIPTION "Provide an Helloworld program") +set(PROJECT_AUTHOR "Iot-Team") +set(PROJECT_AUTHOR_MAIL "secretaria@iot.bzh") +set(PROJECT_LICENSE "APL2.0") +set(PROJECT_LANGUAGES,"C") + +# Where are stored default templates files from submodule or subtree app-templates in your project tree +# relative to the root project directory +set(PROJECT_APP_TEMPLATES_DIR "conf.d/app-templates") + +# Where are stored your external libraries for your project. This is 3rd party library that you don't maintain +# but used and must be built and linked. +# set(PROJECT_LIBDIR "libs") + +# Where are stored data for your application. Pictures, static resources must be placed in that folder. +# set(PROJECT_RESOURCES "data") + +# Which directories inspect to find CMakeLists.txt target files +# set(PROJECT_SRC_DIR_PATTERN "*") + +# Compilation Mode (DEBUG, RELEASE) +# ---------------------------------- +set(CMAKE_BUILD_TYPE "DEBUG") + +# Kernel selection if needed. You can choose between a +# mandatory version to impose a minimal version. +# Or check Kernel minimal version and just print a Warning +# about missing features and define a preprocessor variable +# to be used as preprocessor condition in code to disable +# incompatibles features. Preprocessor define is named +# KERNEL_MINIMAL_VERSION_OK. +# +# NOTE*** FOR NOW IT CHECKS KERNEL Yocto environment and +# Yocto SDK Kernel version. +# ----------------------------------------------- +#set (kernel_mandatory_version 4.8) +#set (kernel_minimal_version 4.8) + +# Compiler selection if needed. Impose a minimal version. +# ----------------------------------------------- +set (gcc_minimal_version 4.9) + +# PKG_CONFIG required packages +# ----------------------------- + + +# Print a helper message when every thing is finished +# ---------------------------------------------------- + +# Customize link option +# ----------------------------- +#list(APPEND link_libraries -an-option) + +# Compilation options definition +# Use CMake generator expressions to specify only for a specific language +# Values are prefilled with default options that is currently used. +# Either separate options with ";", or each options must be quoted separately +# DO NOT PUT ALL OPTION QUOTED AT ONCE , COMPILATION COULD FAILED ! +# ---------------------------------------------------------------------------- +#set(COMPILE_OPTIONS "-Wall" "-Wextra" "-Wconversion" "-Wno-unused-parameter" "-Wno-sign-compare" "-Wno-sign-conversion" "-Werror=maybe-uninitialized" "-Werror=implicit-function-declaration" "-ffunction-sections" "-fdata-sections" "-fPIC" CACHE STRING "Compilation flags") +#set(C_COMPILE_OPTIONS "" CACHE STRING "Compilation flags for C language.") +#set(CXX_COMPILE_OPTIONS "" CACHE STRING "Compilation flags for C++ language.") +#set(PROFILING_COMPILE_OPTIONS "-g" "-O0" "-pg" "-Wp,-U_FORTIFY_SOURCE" CACHE STRING "Compilation flags for PROFILING build type.") +#set(DEBUG_COMPILE_OPTIONS "-g" "-ggdb" "-Wp,-U_FORTIFY_SOURCE" CACHE STRING "Compilation flags for DEBUG build type.") +#set(CCOV_COMPILE_OPTIONS "-g" "-O2" "--coverage" CACHE STRING "Compilation flags for CCOV build type.") +#set(RELEASE_COMPILE_OPTIONS "-g" "-O2" CACHE STRING "Compilation flags for RELEASE build type.") + +# Print a helper message when every thing is finished +# ---------------------------------------------------- +#set(CLOSING_MESSAGE "") +#set(PACKAGE_MESSAGE "Install widget file using in the target : afm-util install ${PROJECT_NAME}.wgt") + +# (BUG!!!) as PKG_CONFIG_PATH does not work [should be an env variable] +# --------------------------------------------------------------------- +set(CMAKE_INSTALL_PREFIX $ENV{HOME}/opt) +set(CMAKE_PREFIX_PATH ${CMAKE_INSTALL_PREFIX}/lib64/pkgconfig ${CMAKE_INSTALL_PREFIX}/lib/pkgconfig) +set(LD_LIBRARY_PATH ${CMAKE_INSTALL_PREFIX}/lib64 ${CMAKE_INSTALL_PREFIX}/lib) + + +# Mandatory widget Mimetype specification of the main unit +# -------------------------------------------------------------------------- +# Choose between : +#- text/html : HTML application, +# content.src designates the home page of the application +# +#- application/vnd.agl.native : AGL compatible native, +# content.src designates the relative path of the binary. +# +# - application/vnd.agl.service: AGL service, content.src is not used. +# +#- ***application/x-executable***: Native application, +# content.src designates the relative path of the binary. +# For such application, only security setup is made. +# +set(WIDGET_TYPE application/vnd.agl.service) + +# Mandatory Widget entry point file of the main unit +# -------------------------------------------------------------- +# This is the file that will be executed, loaded, +# at launch time by the application framework. +# +set(WIDGET_ENTRY_POINT config.xml) + +# Optional dependencies order +# --------------------------- +#set(EXTRA_DEPENDENCIES_ORDER) + +# Optional Extra global include path +# ----------------------------------- +#set(EXTRA_INCLUDE_DIRS) + +# Optional extra libraries +# ------------------------- +#set(EXTRA_LINK_LIBRARIES) + +# Optional force binding installation +# ------------------------------------ +# set(BINDINGS_INSTALL_PREFIX PrefixPath ) + +# Optional force binding Linking flag +# ------------------------------------ +# set(BINDINGS_LINK_FLAG LinkOptions ) + +# Optional force package prefix generation, like widget +# ----------------------------------------------------- +# set(PKG_PREFIX DestinationPath) + +# Optional Application Framework security token +# and port use for remote debugging. +#------------------------------------------------------------ +#set(AFB_TOKEN "" CACHE PATH "Default AFB_TOKEN") +#set(AFB_REMPORT "1234" CACHE PATH "Default AFB_TOKEN") + +# Optional schema validator about now only XML, LUA and JSON +# are supported +#------------------------------------------------------------ +#set(LUA_CHECKER "luac" CACHE STRING "LUA compiler") +#set(XML_CHECKER "xmllint" CACHE STRING "XML linter") +#set(JSON_CHECKER "json_verify" CACHE STRING "JSON linter") + +# This include is mandatory and MUST happens at the end +# of this file, else you expose you to unexpected behavior +# ----------------------------------------------------------- +include(${PROJECT_APP_TEMPLATES_DIR}/cmake/common.cmake) diff --git a/test/fixtures/helloworld/helloworld/CMakeLists.txt b/test/fixtures/helloworld/helloworld/CMakeLists.txt new file mode 100644 index 0000000..373a6f5 --- /dev/null +++ b/test/fixtures/helloworld/helloworld/CMakeLists.txt @@ -0,0 +1,36 @@ +########################################################################### +# Copyright 2015, 2016, 2017 IoT.bzh +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +########################################################################### + +# Add target to project dependency list +PROJECT_TARGET_ADD(helloworld) + + # Define project Targets + file(GLOB sourcelist "*.c") + + # Define project Targets + ADD_LIBRARY(${TARGET_NAME} MODULE ${sourcelist}) + + # Binder exposes a unique public entry point + SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES + PREFIX "" + LABELS "BINDING" + LINK_FLAGS ${BINDINGS_LINK_FLAG} + OUTPUT_NAME ${TARGET_NAME} + ) + + TARGET_LINK_LIBRARIES(${TARGET_NAME} + ${link_libraries} + ) diff --git a/test/fixtures/helloworld/helloworld/helloworld.c b/test/fixtures/helloworld/helloworld/helloworld.c new file mode 100644 index 0000000..94ebcdc --- /dev/null +++ b/test/fixtures/helloworld/helloworld/helloworld.c @@ -0,0 +1,6 @@ +#include + +int main() { + printf ("Hello, World!\n"); + return 0; +} -- cgit 1.2.3-korg From 83fad88204387d196f755c718de40828c08dc7ac Mon Sep 17 00:00:00 2001 From: Clément Bénier Date: Mon, 20 Aug 2018 15:43:22 +0200 Subject: test exec/sdk: use sdk for building exec project MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit source sdk before building helloworld project fix sdks misconfiguration and multiple sdk installs Change-Id: I019e6b6e2704737774e93f08fb79d2f4a84a12b9 Signed-off-by: Clément Bénier --- test/exec_test.go | 25 +++++++++++++++-- test/sdks_test.go | 76 ++++++++++++++++++++++++++++++++++++++++++-------- test/target_test.go | 13 +++++++-- test/xdsserver_test.go | 17 ++--------- 4 files changed, 102 insertions(+), 29 deletions(-) (limited to 'test/exec_test.go') diff --git a/test/exec_test.go b/test/exec_test.go index f2d48ce..ff67322 100644 --- a/test/exec_test.go +++ b/test/exec_test.go @@ -53,6 +53,15 @@ func flushChannelExec(channel chan xsapiv1.ExecOutMsg, ms time.Duration) { } func TestExec(t *testing.T) { helloworldDir := InitExec(t) + chSdks := make(chan xsapiv1.SDK) + defer close(chSdks) + sdk := xsapiv1.SDKInstallArgs{ + ID: "", + Filename: sdkFileName, + Force: false, + } + ConnectSDKStateChange(t, sCli, chSdks) + sdkRes := installFakeSdk(t, sdk, chSdks) var cfgArray []xsapiv1.FolderConfig assert.Nil(t, HTTPCli.Get("/folders", &cfgArray)) @@ -77,7 +86,12 @@ func TestExec(t *testing.T) { chExec <- ev }) - cmd := "cd " + fPrj.ClientPath + sdkSourceFile := path.Join(sdkRes.Path, "environment-setup-corei7-64-native-linux") + cmd := "source " + sdkSourceFile + cmd = cmd + " && " + cmd = cmd + "unset SDKTARGETSYSROOT" + cmd = cmd + " && " + cmd = cmd + "cd " + fPrj.ClientPath cmd = cmd + " && " cmd = cmd + "mkdir -p build" cmd = cmd + " && " @@ -93,7 +107,11 @@ func TestExec(t *testing.T) { assert.Nil(t, HTTPCli.Post("/exec", exec, &execRes)) flushChannelExec(chExec, 1000) - cmd = "cd " + fPrj.ClientPath + cmd = "source " + sdkSourceFile + cmd = cmd + " && " + cmd = cmd + "unset SDKTARGETSYSROOT" + cmd = cmd + " && " + cmd = cmd + "cd " + fPrj.ClientPath cmd = cmd + "&&" cmd = cmd + "cd build" cmd = cmd + "&&" @@ -107,4 +125,7 @@ func TestExec(t *testing.T) { assert.Nil(t, err) assert.Nil(t, HTTPCli.Delete("/folders/"+cfg.ID, &cfg)) + + RemoveSdk(t, sdkRes, chSdks) + DisconnectSDKStateChange(t, sCli) } diff --git a/test/sdks_test.go b/test/sdks_test.go index 3232fa4..c00966f 100644 --- a/test/sdks_test.go +++ b/test/sdks_test.go @@ -17,9 +17,11 @@ package xdsservertest import ( + "log" "os" "path" "regexp" + "strings" "testing" "time" @@ -27,6 +29,20 @@ import ( "github.com/stretchr/testify/assert" ) +var cpt int + +/*flush channel with timeout*/ +func flushChannelSdk(channel chan xsapiv1.SDK, ms time.Duration) { + timeoutB := false + for !timeoutB { + select { + case <-channel: + case <-time.After(ms * time.Millisecond): + timeoutB = true + } + } +} + func ConnectSDKStateChange(t *testing.T, sCli *IOSockClient, channel chan xsapiv1.SDK) { sCli.Conn.On(xsapiv1.EVTSDKStateChange, func(e xsapiv1.EventMsg) { @@ -38,12 +54,42 @@ func ConnectSDKStateChange(t *testing.T, sCli *IOSockClient, channel chan xsapiv assert.Nil(t, HTTPCli.Post("/events/register", args, nil)) } +func DisconnectSDKStateChange(t *testing.T, sCli *IOSockClient) { + args := xsapiv1.EventRegisterArgs{Name: xsapiv1.EVTSDKStateChange} + assert.Nil(t, HTTPCli.Post("/events/unregister", args, nil)) +} + +func InitSdkDir() { + sdkDir := os.Getenv(envXdtSdk) + os.MkdirAll(sdkDir, 0755) + currentDir, err := os.Getwd() + if err != nil { + log.Fatal(err) + } + if err := Copy(path.Join(currentDir, sdkFile), path.Join(sdkDir, sdkFileName)); err != nil { + log.Fatal(err) + } +} + +func RemoveSdk(t *testing.T, sdk xsapiv1.SDK, chSdks chan xsapiv1.SDK) { + assert.Nil(t, HTTPCli.Delete("/sdks/"+sdk.ID, &sdk)) + sdkFromEvt := <-chSdks //Uninstalling + assert.Equal(t, sdk.ID, sdkFromEvt.ID) + assert.Equal(t, sdkFromEvt.Status, "Un-installing") + sdkFromEvt = <-chSdks //not installed + assert.Equal(t, sdkFromEvt.Status, "Not Installed") + os.RemoveAll(path.Join(os.Getenv(envXdtSdk), sdk.Profile)) + os.Remove(strings.Replace(sdk.URL, "file://", "", 1)) +} + func TestSdks(t *testing.T) { + cpt = 0 + InitSdkDir() var sdkArray []xsapiv1.SDK assert.Nil(t, HTTPCli.Get("/sdks", &sdkArray)) - _, err := os.Stat(path.Join(sdkDir, "sdks_latest.json")) + _, err := os.Stat(path.Join(os.Getenv(envXdtSdk), "sdks_latest.json")) + time.Sleep(1000 * time.Millisecond) assert.Nil(t, err) - t.Logf("Connect websocket with url=%v clientId=%v\n", prefixURL, HTTPCli.GetClientID()) chSdks := make(chan xsapiv1.SDK) defer close(chSdks) @@ -61,25 +107,31 @@ func TestSdks(t *testing.T) { var sdkRes xsapiv1.SDK assert.Nil(t, HTTPCli.Post("/sdks", sdk, &sdkRes)) assert.Equal(t, sdkRes.Status, "Installing") - time.Sleep(1 * time.Millisecond) + sdkFromEvent := <-chSdks + assert.Equal(t, sdkRes.ID, sdkFromEvent.ID) + assert.Equal(t, sdkFromEvent.Status, "Installing") + assert.Nil(t, HTTPCli.Post("/sdks/abortinstall", sdk, &sdkRes)) assert.Equal(t, sdkRes.Status, "Not Installed") - time.Sleep(1 * time.Millisecond) - sdkFromEvent := <-chSdks + sdkFromEvent = <-chSdks assert.Equal(t, sdkRes.ID, sdkFromEvent.ID) assert.Equal(t, sdkRes.Status, sdkFromEvent.Status) } } func installFakeSdk(t *testing.T, sdkInstall xsapiv1.SDKInstallArgs, chSdks chan xsapiv1.SDK) xsapiv1.SDK { + InitSdkDir() var sdkRes xsapiv1.SDK assert.Nil(t, HTTPCli.Post("/sdks", sdkInstall, &sdkRes)) assert.Equal(t, sdkRes.Status, "Installing") - /*waiting for SDKStateChange event from channel*/ sdkFromEvent := <-chSdks - t.Log(sdkFromEvent) + assert.Equal(t, sdkRes.ID, sdkFromEvent.ID) + assert.Equal(t, sdkFromEvent.Status, "Installing") + /*waiting for SDKStateChange event from channel*/ + sdkFromEvent = <-chSdks assert.Equal(t, sdkRes.ID, sdkFromEvent.ID) assert.Equal(t, "Installed", sdkFromEvent.Status) + assert.Equal(t, sdkFromEvent.LastError, "") return sdkFromEvent } @@ -94,10 +146,12 @@ func TestInstallFakeSdk(t *testing.T) { defer close(chSdks) ConnectSDKStateChange(t, sCli, chSdks) installFakeSdk(t, sdk, chSdks) - var sdkRes xsapiv1.SDK - assert.NotNil(t, HTTPCli.Post("/sdks", sdk, &sdkRes)) + + /*test force install*/ sdk.Force = true - //installFakeSdk(t, sdk, chSdks) + sdkRes := installFakeSdk(t, sdk, chSdks) + RemoveSdk(t, sdkRes, chSdks) + DisconnectSDKStateChange(t, sCli) } func TestSdksError(t *testing.T) { @@ -108,7 +162,7 @@ func TestSdksError(t *testing.T) { } var sdkRes xsapiv1.SDK assert.NotNil(t, HTTPCli.Post("/sdks", sdk, &sdkRes)) - sdk.ID = "42885c24-374e-3ef0-9723-0ce8a05191aa" + sdk.ID = "42885c24-374e-3ef0-9723-0c8a05191aa" assert.NotNil(t, HTTPCli.Post("/sdks", sdk, &sdkRes)) sdk.Filename = "fake" assert.NotNil(t, HTTPCli.Post("/sdks", sdk, &sdkRes)) diff --git a/test/target_test.go b/test/target_test.go index 401c641..e222505 100644 --- a/test/target_test.go +++ b/test/target_test.go @@ -147,6 +147,13 @@ func AddTerms(t *testing.T, nbTerms int, listID []string, chTermEvt chan xsapiv1 } func PostTerms(t *testing.T, post string, chTermEvt chan xsapiv1.TerminalConfig) { + var status string + switch post { + case "open": + status = "Open" + case "close": + status = "Closing" + } var targets []xsapiv1.TargetConfig assert.Nil(t, HTTPCli.Get("/targets", &targets)) for i := 0; i < len(targets); i++ { @@ -155,12 +162,14 @@ func PostTerms(t *testing.T, post string, chTermEvt chan xsapiv1.TerminalConfig) listTermsID := make([]string, len(terms)) for j := 0; j < len(terms); j++ { var term xsapiv1.TerminalConfig - assert.Nil(t, HTTPCli.Post("/targets/"+targets[i].ID+"/terminals/"+terms[j].ID+"/"+post, term, &term)) + assert.Nil(t, HTTPCli.Post("/targets/"+targets[i].ID+"/terminals/"+terms[j].ID+"/"+post, terms[j], &term)) termEvt := <-chTermEvt //waiting for event terminalStateChange assert.Equal(t, term.ID, termEvt.ID) - assert.True(t, strings.EqualFold(termEvt.Status, post)) + assert.Equal(t, term.Status, status) + assert.Equal(t, termEvt.Status, status) listTermsID[i] = term.ID } + time.Sleep(10 * time.Millisecond) for j := 0; j < len(listTermsID); j++ { var term xsapiv1.TerminalConfig assert.Nil(t, HTTPCli.Get("/targets/"+targets[i].ID+"/terminals/"+listTermsID[i], &term)) diff --git a/test/xdsserver_test.go b/test/xdsserver_test.go index 585ad50..ba56321 100644 --- a/test/xdsserver_test.go +++ b/test/xdsserver_test.go @@ -22,7 +22,6 @@ import ( "log" "os" "os/exec" - "path" "sync" "testing" "time" @@ -46,7 +45,6 @@ type IOSockClient struct { //global client var HTTPCli *common.HTTPClient var logDir string -var sdkDir string var sCli *IOSockClient func Copy(src, dst string) error { @@ -81,7 +79,7 @@ func initEnv(launchProcess bool) { if err := os.Setenv(envRootCfgDir, rootTestLog); err != nil { log.Fatal(err) } - sdkDir = rootTestLog + "/sdks/" + sdkDir := rootTestLog + "/sdks/" if err := os.Setenv(envXdtSdk, sdkDir); err != nil { log.Fatal(err) } @@ -98,14 +96,6 @@ func initEnv(launchProcess bool) { os.MkdirAll(rootTestLog, 0755) logDir = rootTestLog + "/logs/" os.MkdirAll(logDir, 0755) - os.MkdirAll(sdkDir, 0755) - currentDir, err := os.Getwd() - if err != nil { - log.Fatal(err) - } - if err := Copy(path.Join(currentDir, sdkFile), path.Join(sdkDir, sdkFileName)); err != nil { - log.Fatal(err) - } } func launchXdsServer(proc **os.Process) *os.File { @@ -180,11 +170,12 @@ func NewIoSocketClient(url, clientID string) (*IOSockClient, error) { sCli.Connected = false }) + log.Printf("Connect websocket with url=%v clientId=%v\n", prefixURL, HTTPCli.GetClientID()) return sCli, nil } func TestMain(m *testing.M) { launchProcess := true - log.Printf("TestMain: launchProcess is %v", launchProcess) + log.Printf("TestMain: launchProcess is %v, so launching xds-server", launchProcess) initEnv(launchProcess) var proc *os.Process @@ -211,8 +202,6 @@ func TestMain(m *testing.M) { log.Fatal(err) } - log.Printf("HTTPCli id is %v", HTTPCli.GetClientID()) - if HTTPCli == nil { log.Fatal("HTTPCLi is nil") } -- cgit 1.2.3-korg From 72bb1c521aff5bb166db287ef426b243166d8927 Mon Sep 17 00:00:00 2001 From: Clément Bénier Date: Mon, 20 Aug 2018 17:39:39 +0200 Subject: tests: add comments and logs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I31ef0fa20a74f76b696ac9cb768fac18e2197ea5 Signed-off-by: Clément Bénier --- test/config_test.go | 1 + test/exec_test.go | 24 ++++++++++++++++++++---- test/folders_test.go | 16 ++++++++++++++++ test/sdks_test.go | 28 ++++++++++++++++++++++------ test/target_test.go | 27 +++++++++++++++++++++++++-- test/xdsserver_test.go | 12 +++++++----- 6 files changed, 91 insertions(+), 17 deletions(-) (limited to 'test/exec_test.go') diff --git a/test/config_test.go b/test/config_test.go index ad6ea1b..da56188 100644 --- a/test/config_test.go +++ b/test/config_test.go @@ -42,6 +42,7 @@ func CheckIP(ipconfig string) bool { func TestConfig(t *testing.T) { var cfg xsapiv1.APIConfig assert.Nil(t, HTTPCli.Get("/config", &cfg)) + t.Logf("Config is %v", cfg) re := regexp.MustCompile("^[0-9a-z]+-[0-9a-z]+-[0-9a-z]+-[0-9a-z]+-[0-9a-z]+$") assert.True(t, re.MatchString(cfg.ServerUID)) //ID diff --git a/test/exec_test.go b/test/exec_test.go index ff67322..8759dbd 100644 --- a/test/exec_test.go +++ b/test/exec_test.go @@ -29,11 +29,15 @@ import ( ) func InitExec(t *testing.T) string { + t.Logf("Create helloworld directory with app-templates") + /*copy helloworld from fixtures to envRootCfgDir*/ helloworldDir := path.Join(os.Getenv(envRootCfgDir), "helloworld") cmd := exec.Command("cp", "-r", helloworldFixturesDir, helloworldDir) var out bytes.Buffer cmd.Stdout = &out assert.Nil(t, cmd.Run()) + + /*clone submodules app templates into helloworld*/ subHelloworldAppTemplateDir := path.Join(helloworldDir, "conf.d", "app-templates") cmd = exec.Command("git", "clone", "https://gerrit.automotivelinux.org/gerrit/p/apps/app-templates.git", subHelloworldAppTemplateDir) assert.Nil(t, cmd.Run()) @@ -53,6 +57,7 @@ func flushChannelExec(channel chan xsapiv1.ExecOutMsg, ms time.Duration) { } func TestExec(t *testing.T) { helloworldDir := InitExec(t) + /*channel for SDK events*/ chSdks := make(chan xsapiv1.SDK) defer close(chSdks) sdk := xsapiv1.SDKInstallArgs{ @@ -63,6 +68,7 @@ func TestExec(t *testing.T) { ConnectSDKStateChange(t, sCli, chSdks) sdkRes := installFakeSdk(t, sdk, chSdks) + /*check there is no project*/ var cfgArray []xsapiv1.FolderConfig assert.Nil(t, HTTPCli.Get("/folders", &cfgArray)) assert.Equal(t, len(cfgArray), 0) @@ -76,16 +82,20 @@ func TestExec(t *testing.T) { ServerPath: helloworldDir, }, } + /*create project*/ var cfg xsapiv1.FolderConfig assert.Nil(t, HTTPCli.Post("/folders", fPrj, &cfg)) assert.NotNil(t, cfg) + /*channel for ExecOutMsg*/ chExec := make(chan xsapiv1.ExecOutMsg) defer close(chExec) + /*connect to ExecOutEvent*/ sCli.Conn.On(xsapiv1.ExecOutEvent, func(ev xsapiv1.ExecOutMsg) { chExec <- ev }) + /*cmake helloworld project with fake sdk*/ sdkSourceFile := path.Join(sdkRes.Path, "environment-setup-corei7-64-native-linux") cmd := "source " + sdkSourceFile cmd = cmd + " && " @@ -99,14 +109,17 @@ func TestExec(t *testing.T) { cmd = cmd + " && " cmd = cmd + "cmake .." + /*post exec cmd cmake*/ exec := xsapiv1.ExecArgs{ ID: cfg.ID, Cmd: cmd, } var execRes xsapiv1.ExecArgs + t.Logf("exec cmake cmd(%v)", cmd) assert.Nil(t, HTTPCli.Post("/exec", exec, &execRes)) - flushChannelExec(chExec, 1000) + flushChannelExec(chExec, 1000) //waiting for execOutMsg + /*make helloworld project with fake sdk*/ cmd = "source " + sdkSourceFile cmd = cmd + " && " cmd = cmd + "unset SDKTARGETSYSROOT" @@ -117,15 +130,18 @@ func TestExec(t *testing.T) { cmd = cmd + "&&" cmd = cmd + "make" exec.Cmd = cmd + /*post exec cmd make*/ + t.Logf("exec make cmd(%v)", cmd) assert.Nil(t, HTTPCli.Post("/exec", exec, &execRes)) - flushChannelExec(chExec, 1000) + flushChannelExec(chExec, 1000) //waiting for execOutMsg - /*check afb-helloworld.so exists*/ + /*check if helloworld.so exists*/ + t.Log("check that helloworld.so exists") _, err := os.Stat(path.Join(fPrj.ClientPath, "build/helloworld/helloworld.so")) assert.Nil(t, err) + /*deinit*/ assert.Nil(t, HTTPCli.Delete("/folders/"+cfg.ID, &cfg)) - RemoveSdk(t, sdkRes, chSdks) DisconnectSDKStateChange(t, sCli) } diff --git a/test/folders_test.go b/test/folders_test.go index 42db7c2..065e3e3 100644 --- a/test/folders_test.go +++ b/test/folders_test.go @@ -27,6 +27,8 @@ import ( ) func TestFolders(t *testing.T) { + /*init: check there is no folder*/ + t.Log("check there is no folder") var cfgArray []xsapiv1.FolderConfig assert.Nil(t, HTTPCli.Get("/folders", &cfgArray)) assert.Equal(t, len(cfgArray), 0) @@ -41,8 +43,10 @@ func TestFolders(t *testing.T) { }, } var cfg xsapiv1.FolderConfig + t.Logf("create folder: \n%v", fPrj) assert.Nil(t, HTTPCli.Post("/folders", fPrj, &cfg)) assert.NotNil(t, cfg) + t.Logf("result folder: \n%v", cfg) isCfgPrjMatch := func(fPrj xsapiv1.FolderConfig, cfg xsapiv1.FolderConfig) { re := regexp.MustCompile("^[0-9a-z]+-[0-9a-z]+-[0-9a-z]+-[0-9a-z]+-[0-9a-z]+$") @@ -70,18 +74,23 @@ func TestFolders(t *testing.T) { /*create/delete folders*/ var cfgArrayBis []xsapiv1.FolderConfig assert.Nil(t, HTTPCli.Post("/folders", fPrj, &cfg)) + t.Logf("create folder with id=%v", cfg.ID) assert.Nil(t, HTTPCli.Post("/folders", fPrj, &cfg)) + t.Logf("create folder with id=%v", cfg.ID) assert.Nil(t, HTTPCli.Get("/folders", &cfgArray)) assert.Equal(t, len(cfgArray), 3) assert.Nil(t, HTTPCli.Delete("/folders/"+cfgArray[1].ID, &cfg)) + t.Logf("delete folder with id=%v", cfg.ID) assert.Equal(t, cfg, cfgArray[1]) assert.Nil(t, HTTPCli.Get("/folders", &cfgArrayBis)) assert.Equal(t, len(cfgArrayBis), 2) assert.Nil(t, HTTPCli.Delete("/folders/"+cfgArray[0].ID, &cfg)) + t.Logf("delete folder with id=%v", cfg.ID) assert.Equal(t, cfg, cfgArray[0]) assert.Nil(t, HTTPCli.Get("/folders", &cfgArrayBis)) assert.Equal(t, len(cfgArrayBis), 1) assert.Nil(t, HTTPCli.Delete("/folders/"+cfgArray[2].ID, &cfg)) + t.Logf("delete folder with id=%v", cfg.ID) assert.Equal(t, cfg, cfgArray[2]) assert.Nil(t, HTTPCli.Get("/folders", &cfgArrayBis)) assert.Equal(t, len(cfgArrayBis), 0) @@ -100,16 +109,19 @@ func TestFoldersEmptyValues(t *testing.T) { var cfg xsapiv1.FolderConfig /*ServerPath is empty*/ assert.NotNil(t, HTTPCli.Post("/folders", fPrj, &cfg)) + t.Logf("error while creating folder with empty serverpath \n%v", fPrj) fPrj.DataPathMap.ServerPath = logDir + "sameserverpath" fPrj.ClientPath = "" /*ClientPath is Empty*/ assert.NotNil(t, HTTPCli.Post("/folders", fPrj, &cfg)) + t.Logf("error while creating folder with empty clientpath \n%v", fPrj) fPrj.ClientPath = "logDir" fPrj.Type = "" /*Type is empty*/ assert.NotNil(t, HTTPCli.Post("/folders", fPrj, &cfg)) + t.Logf("error while creating folder with empty type \n%v", fPrj) var cfgArray []xsapiv1.FolderConfig assert.Nil(t, HTTPCli.Get("/folders", &cfgArray)) @@ -130,6 +142,7 @@ func TestFoldersPathMapConfig(t *testing.T) { var cfg xsapiv1.FolderConfig /*file not present*/ assert.NotNil(t, HTTPCli.Post("/folders", fPrj, &cfg)) + t.Logf("error while creating folder with no checkfile \n%v", fPrj) var checkFileClient = fPrj.ClientPath + "/checkfile" var checkFileServer = fPrj.DataPathMap.ServerPath + "/checkfile" @@ -147,14 +160,17 @@ func TestFoldersPathMapConfig(t *testing.T) { } /*file content differ*/ assert.NotNil(t, HTTPCli.Post("/folders", fPrj, &cfg)) + t.Logf("error while creating folder with different checkfiles \n%v", fPrj) /*write same message*/ if _, err := file.WriteString(fPrj.DataPathMap.CheckContent); err != nil { t.Log(err) } assert.Nil(t, HTTPCli.Post("/folders", fPrj, &cfg)) + t.Logf("create folder with same checkfiles \n%v", fPrj) /*check server msg: ServerUID needed*/ + t.Logf("check server msg") var APIcfg xsapiv1.APIConfig assert.Nil(t, HTTPCli.Get("/config", &APIcfg)) msg := "Pathmap checked message written by xds-server ID: " + APIcfg.ServerUID + "\n" diff --git a/test/sdks_test.go b/test/sdks_test.go index c00966f..1e3298f 100644 --- a/test/sdks_test.go +++ b/test/sdks_test.go @@ -60,6 +60,7 @@ func DisconnectSDKStateChange(t *testing.T, sCli *IOSockClient) { } func InitSdkDir() { + /*create sdk dir*/ sdkDir := os.Getenv(envXdtSdk) os.MkdirAll(sdkDir, 0755) currentDir, err := os.Getwd() @@ -72,29 +73,31 @@ func InitSdkDir() { } func RemoveSdk(t *testing.T, sdk xsapiv1.SDK, chSdks chan xsapiv1.SDK) { + t.Logf("remove sdk %v", sdk.ID) assert.Nil(t, HTTPCli.Delete("/sdks/"+sdk.ID, &sdk)) - sdkFromEvt := <-chSdks //Uninstalling + sdkFromEvt := <-chSdks //waiting for event Uninstalling assert.Equal(t, sdk.ID, sdkFromEvt.ID) assert.Equal(t, sdkFromEvt.Status, "Un-installing") - sdkFromEvt = <-chSdks //not installed + sdkFromEvt = <-chSdks //waiting for event not installed assert.Equal(t, sdkFromEvt.Status, "Not Installed") os.RemoveAll(path.Join(os.Getenv(envXdtSdk), sdk.Profile)) os.Remove(strings.Replace(sdk.URL, "file://", "", 1)) } func TestSdks(t *testing.T) { - cpt = 0 InitSdkDir() + /*get sdk list from sdk_latest.json*/ var sdkArray []xsapiv1.SDK assert.Nil(t, HTTPCli.Get("/sdks", &sdkArray)) _, err := os.Stat(path.Join(os.Getenv(envXdtSdk), "sdks_latest.json")) - time.Sleep(1000 * time.Millisecond) assert.Nil(t, err) + /*create channel fro SDK event*/ chSdks := make(chan xsapiv1.SDK) defer close(chSdks) ConnectSDKStateChange(t, sCli, chSdks) + /*checking startup installing of SDKs*/ for i := 0; i < len(sdkArray); i++ { re := regexp.MustCompile("^[0-9a-z]+-[0-9a-z]+-[0-9a-z]+-[0-9a-z]+-[0-9a-z]+$") assert.True(t, re.MatchString(sdkArray[i].ID)) @@ -105,15 +108,19 @@ func TestSdks(t *testing.T) { assert.Equal(t, sdkArray[i], sdk) var sdkRes xsapiv1.SDK + /*install sdk*/ + t.Logf("install sdk %v", sdk.Name) assert.Nil(t, HTTPCli.Post("/sdks", sdk, &sdkRes)) assert.Equal(t, sdkRes.Status, "Installing") - sdkFromEvent := <-chSdks + sdkFromEvent := <-chSdks //waiting for installing event assert.Equal(t, sdkRes.ID, sdkFromEvent.ID) assert.Equal(t, sdkFromEvent.Status, "Installing") + /*abort sdk install*/ + t.Logf("abort install sdk %v", sdk.Name) assert.Nil(t, HTTPCli.Post("/sdks/abortinstall", sdk, &sdkRes)) assert.Equal(t, sdkRes.Status, "Not Installed") - sdkFromEvent = <-chSdks + sdkFromEvent = <-chSdks //waiting for not installed status*/ assert.Equal(t, sdkRes.ID, sdkFromEvent.ID) assert.Equal(t, sdkRes.Status, sdkFromEvent.Status) } @@ -123,6 +130,7 @@ func installFakeSdk(t *testing.T, sdkInstall xsapiv1.SDKInstallArgs, chSdks chan InitSdkDir() var sdkRes xsapiv1.SDK assert.Nil(t, HTTPCli.Post("/sdks", sdkInstall, &sdkRes)) + t.Logf("Install fake sdk %v (force=%v)", sdkRes.Name, sdkInstall.Force) assert.Equal(t, sdkRes.Status, "Installing") sdkFromEvent := <-chSdks assert.Equal(t, sdkRes.ID, sdkFromEvent.ID) @@ -132,6 +140,7 @@ func installFakeSdk(t *testing.T, sdkInstall xsapiv1.SDKInstallArgs, chSdks chan assert.Equal(t, sdkRes.ID, sdkFromEvent.ID) assert.Equal(t, "Installed", sdkFromEvent.Status) assert.Equal(t, sdkFromEvent.LastError, "") + t.Logf("Fake sdk %v installed", sdkFromEvent.Name) return sdkFromEvent } @@ -160,10 +169,17 @@ func TestSdksError(t *testing.T) { Filename: "", Force: false, } + t.Logf("error while installing sdk with no ID and no Filename") var sdkRes xsapiv1.SDK + /*error with no ID no filename*/ assert.NotNil(t, HTTPCli.Post("/sdks", sdk, &sdkRes)) sdk.ID = "42885c24-374e-3ef0-9723-0c8a05191aa" + t.Logf("error while installing sdk with a fake id=%v", sdk.ID) + /*error with fake ID*/ assert.NotNil(t, HTTPCli.Post("/sdks", sdk, &sdkRes)) + sdk.ID = "" sdk.Filename = "fake" + t.Logf("error while installing sdk with a fake filename=%v", sdk.Filename) + /*error with fake filename*/ assert.NotNil(t, HTTPCli.Post("/sdks", sdk, &sdkRes)) } diff --git a/test/target_test.go b/test/target_test.go index e222505..0fcd94d 100644 --- a/test/target_test.go +++ b/test/target_test.go @@ -111,6 +111,7 @@ func AddTargets(t *testing.T, nbTargets int, chTarget chan xsapiv1.TargetConfig) } /*add target*/ assert.Nil(t, HTTPCli.Post("/targets", target, &target)) + t.Logf("add target %v", target.Name) targetEvt := <-chTarget //waiting for event targetAdd assert.Equal(t, target.ID, targetEvt.ID) listID[i] = target.ID @@ -133,6 +134,7 @@ func AddTerms(t *testing.T, nbTerms int, listID []string, chTermEvt chan xsapiv1 } /*add terminal on target*/ assert.Nil(t, HTTPCli.Post("/targets/"+listID[j]+"/terminals", term, &term)) + t.Logf("add terminal %v", term.Name) termEvt := <-chTermEvt //waiting for event terminalAdd*/ assert.Equal(t, term.ID, termEvt.ID) listTermsID[i] = term.ID @@ -162,7 +164,9 @@ func PostTerms(t *testing.T, post string, chTermEvt chan xsapiv1.TerminalConfig) listTermsID := make([]string, len(terms)) for j := 0; j < len(terms); j++ { var term xsapiv1.TerminalConfig + /*post action on term*/ assert.Nil(t, HTTPCli.Post("/targets/"+targets[i].ID+"/terminals/"+terms[j].ID+"/"+post, terms[j], &term)) + t.Logf("%v terminal %v", post, term.Name) termEvt := <-chTermEvt //waiting for event terminalStateChange assert.Equal(t, term.ID, termEvt.ID) assert.Equal(t, term.Status, status) @@ -174,6 +178,7 @@ func PostTerms(t *testing.T, post string, chTermEvt chan xsapiv1.TerminalConfig) var term xsapiv1.TerminalConfig assert.Nil(t, HTTPCli.Get("/targets/"+targets[i].ID+"/terminals/"+listTermsID[i], &term)) assert.True(t, strings.EqualFold(term.Status, post)) + t.Logf("check that term status %v is %v", term.Name, post) } } } @@ -190,10 +195,11 @@ func RemoveTermsTargets(t *testing.T, chTarget chan xsapiv1.TargetConfig, chTerm termEvt := <-chTermEvt assert.Equal(t, term.ID, termEvt.ID) assert.NotNil(t, HTTPCli.Delete("/targets/"+targets[i].ID+"/terminals/"+terms[j].ID, &term)) + t.Logf("remove terminal %v", term.Name) } var tgtRes xsapiv1.TargetConfig assert.Nil(t, HTTPCli.Delete("/targets/"+targets[i].ID, &tgtRes)) - targetEvt := <-chTarget + targetEvt := <-chTarget //waiting for remove terminal event assert.Equal(t, tgtRes.ID, targetEvt.ID) assert.Equal(t, targets[i].ID, tgtRes.ID) } @@ -228,7 +234,7 @@ func TestTarget(t *testing.T) { chTerm <- ev }) - /*open first term*/ + /*open terminals*/ PostTerms(t, "open", chTermEvt) /*just for the first term*/ @@ -241,6 +247,7 @@ func TestTarget(t *testing.T) { t.Fatalf("%vcopy your pub key in authorized_keys\ncat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys", stdoutMsg) } assert.True(t, strings.Contains(stdoutMsg, "Last login")) //first terminal msg should be Last Login + t.Logf("terminal is open, console msg is %v", stdoutMsg) /*create toto file through terminals*/ rootCfgDir := os.Getenv(envRootCfgDir) @@ -251,6 +258,7 @@ func TestTarget(t *testing.T) { totoFileCurrent := totoFile + strconv.Itoa(i) /*send cmd though term*/ data := []byte("echo helloWorld" + strconv.Itoa(i) + " >> " + totoFileCurrent + "\n") + t.Logf("send following command through terminal: %v", string(data)) assert.Nil(t, sCli.Conn.Emit(xsapiv1.TerminalInEvent, data)) flushChannelTerm(chTerm, 50) //waiting for terminal msg @@ -260,6 +268,7 @@ func TestTarget(t *testing.T) { /*send cmd though term*/ data = []byte("cat " + totoFileCurrent + "\n") + t.Logf("send following command through terminal: %v", string(data)) assert.Nil(t, sCli.Conn.Emit(xsapiv1.TerminalInEvent, data)) <-chTerm //cmd sent @@ -267,6 +276,7 @@ func TestTarget(t *testing.T) { flushChannelTerm(chTerm, 50) //flushing what remains /*check that terminal msg is what was written before*/ assert.Equal(t, string(termOut.Stdout), "helloWorld"+strconv.Itoa(i)+"\r\n") + t.Logf("check terminal output msg: %v", string(termOut.Stdout)) } PostTerms(t, "close", chTermEvt) @@ -278,23 +288,32 @@ func TestTarget(t *testing.T) { } func TestTargetErrors(t *testing.T) { + /*cannot create empty target*/ target := xsapiv1.TargetConfig{} var targetRes xsapiv1.TargetConfig assert.NotNil(t, HTTPCli.Post("/targets", target, &targetRes)) + t.Logf("error while creating empty target") + /*check cannot create target with no IP*/ target.Type = xsapiv1.TypeTgtStandard assert.NotNil(t, HTTPCli.Post("/targets", target, &targetRes)) + t.Logf("error while creating target without IP") target.IP = "127.0.0.1" assert.Nil(t, HTTPCli.Post("/targets", target, &targetRes)) + t.Logf("create target %v", targetRes.Name) + /*cannot create empty terminal*/ term := xsapiv1.TerminalConfig{} var termRes xsapiv1.TerminalConfig assert.NotNil(t, HTTPCli.Post("/targets/"+targetRes.ID+"/terminals", term, &termRes)) + t.Logf("error while creating empty terminal") term.Type = xsapiv1.TypeTermSSH assert.NotNil(t, HTTPCli.Post("/targets/"+"1010"+"/terminals", term, &termRes)) + t.Logf("error while creating terminal on an non existing target") assert.Nil(t, HTTPCli.Post("/targets/"+targetRes.ID+"/terminals", term, &termRes)) assert.Nil(t, HTTPCli.Post("/targets/"+targetRes.ID+"/terminals", term, &termRes)) assert.Nil(t, HTTPCli.Post("/targets/"+targetRes.ID+"/terminals", term, &termRes)) assert.Nil(t, HTTPCli.Post("/targets/"+targetRes.ID+"/terminals", term, &termRes)) + t.Logf("create several terminals") /*remove targets and terms*/ var targetArray []xsapiv1.TargetConfig @@ -304,11 +323,15 @@ func TestTargetErrors(t *testing.T) { assert.Nil(t, HTTPCli.Get("/targets/"+targetArray[i].ID+"/terminals", &termArray)) for j := 0; j < len(termArray); j++ { assert.Nil(t, HTTPCli.Delete("/targets/"+targetArray[i].ID+"/terminals/"+termArray[j].ID, &termRes)) + t.Logf("delete terminal %v", termRes.Name) assert.NotNil(t, HTTPCli.Delete("/targets/"+targetArray[i].ID+"/terminals/"+termArray[j].ID, &termRes)) + t.Logf("error while deleting an already deleted terminal %v", termRes.Name) } var tgtRes xsapiv1.TargetConfig assert.Nil(t, HTTPCli.Delete("/targets/"+targetArray[i].ID, &tgtRes)) + t.Logf("delete target %v", tgtRes.Name) assert.Equal(t, targetArray[i].ID, tgtRes.ID) assert.NotNil(t, HTTPCli.Delete("/targets/"+targetArray[i].ID, &tgtRes)) + t.Logf("error while deleting an already deleted target %v", tgtRes.Name) } } diff --git a/test/xdsserver_test.go b/test/xdsserver_test.go index ba56321..b8e98b5 100644 --- a/test/xdsserver_test.go +++ b/test/xdsserver_test.go @@ -69,12 +69,14 @@ func Copy(src, dst string) error { func initEnv(launchProcess bool) { if launchProcess { + /*kill xds-server if needed*/ cmd := exec.Command("killall", "-9", "xds-server") if err := cmd.Start(); err != nil { log.Fatal(err) } cmd.Wait() } + /*set environment variable*/ rootTestLog := "/tmp/xds-server-test" if err := os.Setenv(envRootCfgDir, rootTestLog); err != nil { log.Fatal(err) @@ -92,12 +94,14 @@ func initEnv(launchProcess bool) { if err := os.Setenv("XDS_LOG_SILLY", "1"); err != nil { log.Fatal(err) } + /*remove and recreate working directories*/ os.RemoveAll(rootTestLog) os.MkdirAll(rootTestLog, 0755) logDir = rootTestLog + "/logs/" os.MkdirAll(logDir, 0755) } +/*prepare xds-server process*/ func launchXdsServer(proc **os.Process) *os.File { logFile := logDir + logFileXdsServer file, err := os.OpenFile(logFile, os.O_CREATE|os.O_WRONLY, 0644) @@ -142,7 +146,6 @@ func getHTTPClient(lvl int) (*common.HTTPClient, *os.File) { } func NewIoSocketClient(url, clientID string) (*IOSockClient, error) { - var err error sCli := &IOSockClient{ @@ -152,7 +155,6 @@ func NewIoSocketClient(url, clientID string) (*IOSockClient, error) { Transport: "websocket", Header: make(map[string][]string), }, - //ServerDiscoChan: make(chan Disconnection, 1), } sCli.Options.Header["XDS-SID"] = []string{clientID} @@ -174,6 +176,8 @@ func NewIoSocketClient(url, clientID string) (*IOSockClient, error) { return sCli, nil } func TestMain(m *testing.M) { + /* useful for debugging, preventing from launching xds-server + * it can be launch separetly */ launchProcess := true log.Printf("TestMain: launchProcess is %v, so launching xds-server", launchProcess) initEnv(launchProcess) @@ -183,6 +187,7 @@ func TestMain(m *testing.M) { if launchProcess { fileXdsServer = launchXdsServer(&proc) go func(p *os.Process) { + log.Print("xds-server is launching") if status, err := p.Wait(); err != nil { log.Fatalf("status=%v\n err=%v\n", status, err) } @@ -208,6 +213,3 @@ func TestMain(m *testing.M) { res := m.Run() defer os.Exit(res) } - -func init() { -} -- cgit 1.2.3-korg From b1d091a8c6b2269601a1683e963d0e382cd0f7f6 Mon Sep 17 00:00:00 2001 From: Clément Bénier Date: Tue, 21 Aug 2018 17:56:10 +0200 Subject: test logs: hide log MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit logs are printable with VERBOSE != "" Change-Id: I170aed2e73db673ba6276410b1dddd3389239457 Signed-off-by: Clément Bénier --- test/config_test.go | 2 +- test/exec_test.go | 8 ++++---- test/folders_test.go | 38 +++++++++++++++++++------------------- test/sdks_test.go | 16 ++++++++-------- test/target_test.go | 36 ++++++++++++++++++------------------ test/version_test.go | 4 ++-- test/xdsserver_test.go | 12 ++++++++++++ 7 files changed, 64 insertions(+), 52 deletions(-) (limited to 'test/exec_test.go') diff --git a/test/config_test.go b/test/config_test.go index da56188..2b95e85 100644 --- a/test/config_test.go +++ b/test/config_test.go @@ -42,7 +42,7 @@ func CheckIP(ipconfig string) bool { func TestConfig(t *testing.T) { var cfg xsapiv1.APIConfig assert.Nil(t, HTTPCli.Get("/config", &cfg)) - t.Logf("Config is %v", cfg) + Debugf(t, "Config is %v", cfg) re := regexp.MustCompile("^[0-9a-z]+-[0-9a-z]+-[0-9a-z]+-[0-9a-z]+-[0-9a-z]+$") assert.True(t, re.MatchString(cfg.ServerUID)) //ID diff --git a/test/exec_test.go b/test/exec_test.go index 8759dbd..1ab781a 100644 --- a/test/exec_test.go +++ b/test/exec_test.go @@ -29,7 +29,7 @@ import ( ) func InitExec(t *testing.T) string { - t.Logf("Create helloworld directory with app-templates") + Debugf(t, "Create helloworld directory with app-templates") /*copy helloworld from fixtures to envRootCfgDir*/ helloworldDir := path.Join(os.Getenv(envRootCfgDir), "helloworld") cmd := exec.Command("cp", "-r", helloworldFixturesDir, helloworldDir) @@ -115,7 +115,7 @@ func TestExec(t *testing.T) { Cmd: cmd, } var execRes xsapiv1.ExecArgs - t.Logf("exec cmake cmd(%v)", cmd) + Debugf(t, "exec cmake cmd(%v)", cmd) assert.Nil(t, HTTPCli.Post("/exec", exec, &execRes)) flushChannelExec(chExec, 1000) //waiting for execOutMsg @@ -131,12 +131,12 @@ func TestExec(t *testing.T) { cmd = cmd + "make" exec.Cmd = cmd /*post exec cmd make*/ - t.Logf("exec make cmd(%v)", cmd) + Debugf(t, "exec make cmd(%v)", cmd) assert.Nil(t, HTTPCli.Post("/exec", exec, &execRes)) flushChannelExec(chExec, 1000) //waiting for execOutMsg /*check if helloworld.so exists*/ - t.Log("check that helloworld.so exists") + Debug(t, "check that helloworld.so exists") _, err := os.Stat(path.Join(fPrj.ClientPath, "build/helloworld/helloworld.so")) assert.Nil(t, err) diff --git a/test/folders_test.go b/test/folders_test.go index 065e3e3..10f1dc6 100644 --- a/test/folders_test.go +++ b/test/folders_test.go @@ -28,7 +28,7 @@ import ( func TestFolders(t *testing.T) { /*init: check there is no folder*/ - t.Log("check there is no folder") + Debug(t, "check there is no folder") var cfgArray []xsapiv1.FolderConfig assert.Nil(t, HTTPCli.Get("/folders", &cfgArray)) assert.Equal(t, len(cfgArray), 0) @@ -43,10 +43,10 @@ func TestFolders(t *testing.T) { }, } var cfg xsapiv1.FolderConfig - t.Logf("create folder: \n%v", fPrj) + Debugf(t, "create folder: \n%v", fPrj) assert.Nil(t, HTTPCli.Post("/folders", fPrj, &cfg)) assert.NotNil(t, cfg) - t.Logf("result folder: \n%v", cfg) + Debugf(t, "result folder: \n%v", cfg) isCfgPrjMatch := func(fPrj xsapiv1.FolderConfig, cfg xsapiv1.FolderConfig) { re := regexp.MustCompile("^[0-9a-z]+-[0-9a-z]+-[0-9a-z]+-[0-9a-z]+-[0-9a-z]+$") @@ -74,23 +74,23 @@ func TestFolders(t *testing.T) { /*create/delete folders*/ var cfgArrayBis []xsapiv1.FolderConfig assert.Nil(t, HTTPCli.Post("/folders", fPrj, &cfg)) - t.Logf("create folder with id=%v", cfg.ID) + Debugf(t, "create folder with id=%v", cfg.ID) assert.Nil(t, HTTPCli.Post("/folders", fPrj, &cfg)) - t.Logf("create folder with id=%v", cfg.ID) + Debugf(t, "create folder with id=%v", cfg.ID) assert.Nil(t, HTTPCli.Get("/folders", &cfgArray)) assert.Equal(t, len(cfgArray), 3) assert.Nil(t, HTTPCli.Delete("/folders/"+cfgArray[1].ID, &cfg)) - t.Logf("delete folder with id=%v", cfg.ID) + Debugf(t, "delete folder with id=%v", cfg.ID) assert.Equal(t, cfg, cfgArray[1]) assert.Nil(t, HTTPCli.Get("/folders", &cfgArrayBis)) assert.Equal(t, len(cfgArrayBis), 2) assert.Nil(t, HTTPCli.Delete("/folders/"+cfgArray[0].ID, &cfg)) - t.Logf("delete folder with id=%v", cfg.ID) + Debugf(t, "delete folder with id=%v", cfg.ID) assert.Equal(t, cfg, cfgArray[0]) assert.Nil(t, HTTPCli.Get("/folders", &cfgArrayBis)) assert.Equal(t, len(cfgArrayBis), 1) assert.Nil(t, HTTPCli.Delete("/folders/"+cfgArray[2].ID, &cfg)) - t.Logf("delete folder with id=%v", cfg.ID) + Debugf(t, "delete folder with id=%v", cfg.ID) assert.Equal(t, cfg, cfgArray[2]) assert.Nil(t, HTTPCli.Get("/folders", &cfgArrayBis)) assert.Equal(t, len(cfgArrayBis), 0) @@ -109,19 +109,19 @@ func TestFoldersEmptyValues(t *testing.T) { var cfg xsapiv1.FolderConfig /*ServerPath is empty*/ assert.NotNil(t, HTTPCli.Post("/folders", fPrj, &cfg)) - t.Logf("error while creating folder with empty serverpath \n%v", fPrj) + Debugf(t, "error while creating folder with empty serverpath \n%v", fPrj) fPrj.DataPathMap.ServerPath = logDir + "sameserverpath" fPrj.ClientPath = "" /*ClientPath is Empty*/ assert.NotNil(t, HTTPCli.Post("/folders", fPrj, &cfg)) - t.Logf("error while creating folder with empty clientpath \n%v", fPrj) + Debugf(t, "error while creating folder with empty clientpath \n%v", fPrj) fPrj.ClientPath = "logDir" fPrj.Type = "" /*Type is empty*/ assert.NotNil(t, HTTPCli.Post("/folders", fPrj, &cfg)) - t.Logf("error while creating folder with empty type \n%v", fPrj) + Debugf(t, "error while creating folder with empty type \n%v", fPrj) var cfgArray []xsapiv1.FolderConfig assert.Nil(t, HTTPCli.Get("/folders", &cfgArray)) @@ -142,7 +142,7 @@ func TestFoldersPathMapConfig(t *testing.T) { var cfg xsapiv1.FolderConfig /*file not present*/ assert.NotNil(t, HTTPCli.Post("/folders", fPrj, &cfg)) - t.Logf("error while creating folder with no checkfile \n%v", fPrj) + Debugf(t, "error while creating folder with no checkfile \n%v", fPrj) var checkFileClient = fPrj.ClientPath + "/checkfile" var checkFileServer = fPrj.DataPathMap.ServerPath + "/checkfile" @@ -153,30 +153,30 @@ func TestFoldersPathMapConfig(t *testing.T) { fPrj.DataPathMap.CheckContent = "CheckContent From Client\n" file, err := os.OpenFile(checkFileClient, os.O_CREATE|os.O_RDWR, 0644) if err != nil { - t.Log(err) + Debug(t, err) } if err := os.Symlink(checkFileClient, checkFileServer); err != nil { - t.Log(err) + Debug(t, err) } /*file content differ*/ assert.NotNil(t, HTTPCli.Post("/folders", fPrj, &cfg)) - t.Logf("error while creating folder with different checkfiles \n%v", fPrj) + Debugf(t, "error while creating folder with different checkfiles \n%v", fPrj) /*write same message*/ if _, err := file.WriteString(fPrj.DataPathMap.CheckContent); err != nil { - t.Log(err) + Debug(t, err) } assert.Nil(t, HTTPCli.Post("/folders", fPrj, &cfg)) - t.Logf("create folder with same checkfiles \n%v", fPrj) + Debugf(t, "create folder with same checkfiles \n%v", fPrj) /*check server msg: ServerUID needed*/ - t.Logf("check server msg") + Debugf(t, "check server msg") var APIcfg xsapiv1.APIConfig assert.Nil(t, HTTPCli.Get("/config", &APIcfg)) msg := "Pathmap checked message written by xds-server ID: " + APIcfg.ServerUID + "\n" data, err := ioutil.ReadAll(file) if err != nil { - t.Log(err) + Debug(t, err) } assert.Equal(t, msg, string(data)) diff --git a/test/sdks_test.go b/test/sdks_test.go index 1e3298f..1395b16 100644 --- a/test/sdks_test.go +++ b/test/sdks_test.go @@ -73,7 +73,7 @@ func InitSdkDir() { } func RemoveSdk(t *testing.T, sdk xsapiv1.SDK, chSdks chan xsapiv1.SDK) { - t.Logf("remove sdk %v", sdk.ID) + Debugf(t, "remove sdk %v", sdk.ID) assert.Nil(t, HTTPCli.Delete("/sdks/"+sdk.ID, &sdk)) sdkFromEvt := <-chSdks //waiting for event Uninstalling assert.Equal(t, sdk.ID, sdkFromEvt.ID) @@ -109,7 +109,7 @@ func TestSdks(t *testing.T) { var sdkRes xsapiv1.SDK /*install sdk*/ - t.Logf("install sdk %v", sdk.Name) + Debugf(t, "install sdk %v", sdk.Name) assert.Nil(t, HTTPCli.Post("/sdks", sdk, &sdkRes)) assert.Equal(t, sdkRes.Status, "Installing") sdkFromEvent := <-chSdks //waiting for installing event @@ -117,7 +117,7 @@ func TestSdks(t *testing.T) { assert.Equal(t, sdkFromEvent.Status, "Installing") /*abort sdk install*/ - t.Logf("abort install sdk %v", sdk.Name) + Debugf(t, "abort install sdk %v", sdk.Name) assert.Nil(t, HTTPCli.Post("/sdks/abortinstall", sdk, &sdkRes)) assert.Equal(t, sdkRes.Status, "Not Installed") sdkFromEvent = <-chSdks //waiting for not installed status*/ @@ -130,7 +130,7 @@ func installFakeSdk(t *testing.T, sdkInstall xsapiv1.SDKInstallArgs, chSdks chan InitSdkDir() var sdkRes xsapiv1.SDK assert.Nil(t, HTTPCli.Post("/sdks", sdkInstall, &sdkRes)) - t.Logf("Install fake sdk %v (force=%v)", sdkRes.Name, sdkInstall.Force) + Debugf(t, "Install fake sdk %v (force=%v)", sdkRes.Name, sdkInstall.Force) assert.Equal(t, sdkRes.Status, "Installing") sdkFromEvent := <-chSdks assert.Equal(t, sdkRes.ID, sdkFromEvent.ID) @@ -140,7 +140,7 @@ func installFakeSdk(t *testing.T, sdkInstall xsapiv1.SDKInstallArgs, chSdks chan assert.Equal(t, sdkRes.ID, sdkFromEvent.ID) assert.Equal(t, "Installed", sdkFromEvent.Status) assert.Equal(t, sdkFromEvent.LastError, "") - t.Logf("Fake sdk %v installed", sdkFromEvent.Name) + Debugf(t, "Fake sdk %v installed", sdkFromEvent.Name) return sdkFromEvent } @@ -169,17 +169,17 @@ func TestSdksError(t *testing.T) { Filename: "", Force: false, } - t.Logf("error while installing sdk with no ID and no Filename") + Debugf(t, "error while installing sdk with no ID and no Filename") var sdkRes xsapiv1.SDK /*error with no ID no filename*/ assert.NotNil(t, HTTPCli.Post("/sdks", sdk, &sdkRes)) sdk.ID = "42885c24-374e-3ef0-9723-0c8a05191aa" - t.Logf("error while installing sdk with a fake id=%v", sdk.ID) + Debugf(t, "error while installing sdk with a fake id=%v", sdk.ID) /*error with fake ID*/ assert.NotNil(t, HTTPCli.Post("/sdks", sdk, &sdkRes)) sdk.ID = "" sdk.Filename = "fake" - t.Logf("error while installing sdk with a fake filename=%v", sdk.Filename) + Debugf(t, "error while installing sdk with a fake filename=%v", sdk.Filename) /*error with fake filename*/ assert.NotNil(t, HTTPCli.Post("/sdks", sdk, &sdkRes)) } diff --git a/test/target_test.go b/test/target_test.go index 50483ff..17ac6b8 100644 --- a/test/target_test.go +++ b/test/target_test.go @@ -111,7 +111,7 @@ func AddTargets(t *testing.T, nbTargets int, chTarget chan xsapiv1.TargetConfig) } /*add target*/ assert.Nil(t, HTTPCli.Post("/targets", target, &target)) - t.Logf("add target %v", target.Name) + Debugf(t, "add target %v", target.Name) targetEvt := <-chTarget //waiting for event targetAdd assert.Equal(t, target.ID, targetEvt.ID) listID[i] = target.ID @@ -134,7 +134,7 @@ func AddTerms(t *testing.T, nbTerms int, listID []string, chTermEvt chan xsapiv1 } /*add terminal on target*/ assert.Nil(t, HTTPCli.Post("/targets/"+listID[j]+"/terminals", term, &term)) - t.Logf("add terminal %v", term.Name) + Debugf(t, "add terminal %v", term.Name) termEvt := <-chTermEvt //waiting for event terminalAdd*/ assert.Equal(t, term.ID, termEvt.ID) listTermsID[i] = term.ID @@ -166,7 +166,7 @@ func PostTerms(t *testing.T, post string, chTermEvt chan xsapiv1.TerminalConfig) var term xsapiv1.TerminalConfig /*post action on term*/ assert.Nil(t, HTTPCli.Post("/targets/"+targets[i].ID+"/terminals/"+terms[j].ID+"/"+post, terms[j], &term)) - t.Logf("%v terminal %v", post, term.Name) + Debugf(t, "%v terminal %v", post, term.Name) termEvt := <-chTermEvt //waiting for event terminalStateChange assert.Equal(t, term.ID, termEvt.ID) assert.Equal(t, term.Status, status) @@ -178,7 +178,7 @@ func PostTerms(t *testing.T, post string, chTermEvt chan xsapiv1.TerminalConfig) var term xsapiv1.TerminalConfig assert.Nil(t, HTTPCli.Get("/targets/"+targets[i].ID+"/terminals/"+listTermsID[i], &term)) assert.True(t, strings.EqualFold(term.Status, post)) - t.Logf("check that term status %v is %v", term.Name, post) + Debugf(t, "check that term status %v is %v", term.Name, post) } } } @@ -195,7 +195,7 @@ func RemoveTermsTargets(t *testing.T, chTarget chan xsapiv1.TargetConfig, chTerm termEvt := <-chTermEvt assert.Equal(t, term.ID, termEvt.ID) assert.NotNil(t, HTTPCli.Delete("/targets/"+targets[i].ID+"/terminals/"+terms[j].ID, &term)) - t.Logf("remove terminal %v", term.Name) + Debugf(t, "remove terminal %v", term.Name) } var tgtRes xsapiv1.TargetConfig assert.Nil(t, HTTPCli.Delete("/targets/"+targets[i].ID, &tgtRes)) @@ -273,7 +273,7 @@ func TestTarget(t *testing.T) { totoFileCurrent := totoFile + strconv.Itoa(i) /*send cmd though term*/ data := []byte("echo helloWorld" + strconv.Itoa(i) + " >> " + totoFileCurrent + "\n") - t.Logf("send following command through terminal: %v", string(data)) + Debugf(t, "send following command through terminal: %v", string(data)) assert.Nil(t, sCli.Conn.Emit(xsapiv1.TerminalInEvent, data)) flushChannelTerm(chTerm, 50) //waiting for terminal msg @@ -283,7 +283,7 @@ func TestTarget(t *testing.T) { /*send cmd though term*/ data = []byte("cat " + totoFileCurrent + "\n") - t.Logf("send following command through terminal: %v", string(data)) + Debugf(t, "send following command through terminal: %v", string(data)) assert.Nil(t, sCli.Conn.Emit(xsapiv1.TerminalInEvent, data)) <-chTerm //cmd sent @@ -291,7 +291,7 @@ func TestTarget(t *testing.T) { flushChannelTerm(chTerm, 50) //flushing what remains /*check that terminal msg is what was written before*/ assert.Equal(t, string(termOut.Stdout), "helloWorld"+strconv.Itoa(i)+"\r\n") - t.Logf("check terminal output msg: %v", string(termOut.Stdout)) + Debugf(t, "check terminal output msg: %v", string(termOut.Stdout)) } PostTerms(t, "close", chTermEvt) @@ -307,28 +307,28 @@ func TestTargetErrors(t *testing.T) { target := xsapiv1.TargetConfig{} var targetRes xsapiv1.TargetConfig assert.NotNil(t, HTTPCli.Post("/targets", target, &targetRes)) - t.Logf("error while creating empty target") + Debugf(t, "error while creating empty target") /*check cannot create target with no IP*/ target.Type = xsapiv1.TypeTgtStandard assert.NotNil(t, HTTPCli.Post("/targets", target, &targetRes)) - t.Logf("error while creating target without IP") + Debugf(t, "error while creating target without IP") target.IP = "127.0.0.1" assert.Nil(t, HTTPCli.Post("/targets", target, &targetRes)) - t.Logf("create target %v", targetRes.Name) + Debugf(t, "create target %v", targetRes.Name) /*cannot create empty terminal*/ term := xsapiv1.TerminalConfig{} var termRes xsapiv1.TerminalConfig assert.NotNil(t, HTTPCli.Post("/targets/"+targetRes.ID+"/terminals", term, &termRes)) - t.Logf("error while creating empty terminal") + Debugf(t, "error while creating empty terminal") term.Type = xsapiv1.TypeTermSSH assert.NotNil(t, HTTPCli.Post("/targets/"+"1010"+"/terminals", term, &termRes)) - t.Logf("error while creating terminal on an non existing target") + Debugf(t, "error while creating terminal on an non existing target") assert.Nil(t, HTTPCli.Post("/targets/"+targetRes.ID+"/terminals", term, &termRes)) assert.Nil(t, HTTPCli.Post("/targets/"+targetRes.ID+"/terminals", term, &termRes)) assert.Nil(t, HTTPCli.Post("/targets/"+targetRes.ID+"/terminals", term, &termRes)) assert.Nil(t, HTTPCli.Post("/targets/"+targetRes.ID+"/terminals", term, &termRes)) - t.Logf("create several terminals") + Debugf(t, "create several terminals") /*remove targets and terms*/ var targetArray []xsapiv1.TargetConfig @@ -338,15 +338,15 @@ func TestTargetErrors(t *testing.T) { assert.Nil(t, HTTPCli.Get("/targets/"+targetArray[i].ID+"/terminals", &termArray)) for j := 0; j < len(termArray); j++ { assert.Nil(t, HTTPCli.Delete("/targets/"+targetArray[i].ID+"/terminals/"+termArray[j].ID, &termRes)) - t.Logf("delete terminal %v", termRes.Name) + Debugf(t, "delete terminal %v", termRes.Name) assert.NotNil(t, HTTPCli.Delete("/targets/"+targetArray[i].ID+"/terminals/"+termArray[j].ID, &termRes)) - t.Logf("error while deleting an already deleted terminal %v", termRes.Name) + Debugf(t, "error while deleting an already deleted terminal %v", termRes.Name) } var tgtRes xsapiv1.TargetConfig assert.Nil(t, HTTPCli.Delete("/targets/"+targetArray[i].ID, &tgtRes)) - t.Logf("delete target %v", tgtRes.Name) + Debugf(t, "delete target %v", tgtRes.Name) assert.Equal(t, targetArray[i].ID, tgtRes.ID) assert.NotNil(t, HTTPCli.Delete("/targets/"+targetArray[i].ID, &tgtRes)) - t.Logf("error while deleting an already deleted target %v", tgtRes.Name) + Debugf(t, "error while deleting an already deleted target %v", tgtRes.Name) } } diff --git a/test/version_test.go b/test/version_test.go index 275480b..5373a15 100644 --- a/test/version_test.go +++ b/test/version_test.go @@ -26,11 +26,11 @@ import ( func TestVersion(t *testing.T) { var datVersion map[string]interface{} assert.Nil(t, HTTPCli.Get("/version", &datVersion)) - t.Log(datVersion) + Debug(t, datVersion) ver, present := datVersion["version"] assert.True(t, present) - t.Logf("version is %s", ver.(string)) + Debugf(t, "version is %s", ver.(string)) re := regexp.MustCompile("^v*[0-9]+.[0-9]+.[0-9]+$") assert.True(t, re.MatchString(ver.(string))) } diff --git a/test/xdsserver_test.go b/test/xdsserver_test.go index b8e98b5..89f73a6 100644 --- a/test/xdsserver_test.go +++ b/test/xdsserver_test.go @@ -47,6 +47,18 @@ var HTTPCli *common.HTTPClient var logDir string var sCli *IOSockClient +func Debug(t *testing.T, args ...interface{}) { + if os.Getenv("VERBOSE") != "" { + t.Log(args) + } +} + +func Debugf(t *testing.T, format string, args ...interface{}) { + if os.Getenv("VERBOSE") != "" { + t.Logf(format, args) + } +} + func Copy(src, dst string) error { in, err := os.Open(src) if err != nil { -- cgit 1.2.3-korg From 2fb2226b666e7a8a21dc8b852188b75c06e2cfc8 Mon Sep 17 00:00:00 2001 From: Clément Bénier Date: Tue, 21 Aug 2018 18:54:10 +0200 Subject: test exec: waiting exit event after exec cmd MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I355f9a55e9641ce60c787b8b02f84f35bccc8e67 Signed-off-by: Clément Bénier --- test/exec_test.go | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) (limited to 'test/exec_test.go') diff --git a/test/exec_test.go b/test/exec_test.go index 1ab781a..884ba87 100644 --- a/test/exec_test.go +++ b/test/exec_test.go @@ -22,7 +22,6 @@ import ( "os/exec" "path" "testing" - "time" "gerrit.automotivelinux.org/gerrit/src/xds/xds-server/lib/xsapiv1" "github.com/stretchr/testify/assert" @@ -44,17 +43,6 @@ func InitExec(t *testing.T) string { return helloworldDir } -/*flush channel with timeout*/ -func flushChannelExec(channel chan xsapiv1.ExecOutMsg, ms time.Duration) { - timeoutB := false - for !timeoutB { - select { - case <-channel: - case <-time.After(ms * time.Millisecond): - timeoutB = true - } - } -} func TestExec(t *testing.T) { helloworldDir := InitExec(t) /*channel for SDK events*/ @@ -88,10 +76,10 @@ func TestExec(t *testing.T) { assert.NotNil(t, cfg) /*channel for ExecOutMsg*/ - chExec := make(chan xsapiv1.ExecOutMsg) + chExec := make(chan xsapiv1.ExecExitMsg) defer close(chExec) /*connect to ExecOutEvent*/ - sCli.Conn.On(xsapiv1.ExecOutEvent, func(ev xsapiv1.ExecOutMsg) { + sCli.Conn.On(xsapiv1.ExecExitEvent, func(ev xsapiv1.ExecExitMsg) { chExec <- ev }) @@ -117,7 +105,8 @@ func TestExec(t *testing.T) { var execRes xsapiv1.ExecArgs Debugf(t, "exec cmake cmd(%v)", cmd) assert.Nil(t, HTTPCli.Post("/exec", exec, &execRes)) - flushChannelExec(chExec, 1000) //waiting for execOutMsg + exitMsg := <-chExec + assert.Equal(t, exitMsg.Code, 0) /*make helloworld project with fake sdk*/ cmd = "source " + sdkSourceFile @@ -133,7 +122,8 @@ func TestExec(t *testing.T) { /*post exec cmd make*/ Debugf(t, "exec make cmd(%v)", cmd) assert.Nil(t, HTTPCli.Post("/exec", exec, &execRes)) - flushChannelExec(chExec, 1000) //waiting for execOutMsg + exitMsg = <-chExec + assert.Equal(t, exitMsg.Code, 0) /*check if helloworld.so exists*/ Debug(t, "check that helloworld.so exists") -- cgit 1.2.3-korg