Skip to content

Commit

Permalink
automatedTests: scopy default tests
Browse files Browse the repository at this point in the history
test for connect / disconnect
test for switch tool

Signed-off-by: Ionut Muthi <[email protected]>
  • Loading branch information
IonutMuthi committed Jul 8, 2024
1 parent a4a681a commit 7701128
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
21 changes: 21 additions & 0 deletions JS/scopyDefaultTests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export function connect(){
//CONNECT TO EMU
var deviceID = scopy.addDevice("", "ip:127.0.0.0")
//CONNECT TO DEVICE
scopy.connectDevice(deviceID)
}

export function disconnect(){
//DISCONNECT FROM DEVICE
scopy.disconnectDevice()
exit(0)
}

export function switchToolTest(){
connect()
scopy.switchTool("Time")
scopy.switchTool("DataLogger 0")
scopy.switchTool("Debugger")
scopy.switchTool("Register Map")
disconnect()
}
26 changes: 26 additions & 0 deletions JS/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#! /bin/bash

# get scopy buil path from CMakeCache.txt
scopyBuildDir=$(grep 'SCOPY_BUILD_PATH' ../CMakeCache.txt | awk -F= '{print $2}')

isEmuRunning=TRUE

#if emu is not running start emu at provided path
if ! pgrep -x "iio-emu" > /dev/null; then
isEmuRunning=FALSE
if [ ! -z $1 ]; then
cd $1
iio-emu generic *.xml &
fi
fi
# run scopy functions of provided script
if [ ! -z $2 ]; then
cd $scopyBuildDir
./scopy --script="$2" --script-functions="$3"
fi

#if emu was started by this script stop emu
if [ "$isEmuRunning" = FALSE ]; then
#stop emu
killall -9 iio-emu
fi
9 changes: 9 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
cmake_minimum_required(VERSION 3.5)

# JS AUTOMATED TESTS

# Set build path as CMAKE CACHE variable to use in tests
set(SCOPY_BUILD_PATH ${CMAKE_BINARY_DIR} CACHE STRING "SCOPY_BUILD_PATH" FORCE)

#SCOPY BASE TESTS
add_test(NAME "ConnectionJSTest" COMMAND bash ${CMAKE_SOURCE_DIR}/JS/test.sh "${CMAKE_SOURCE_DIR}/resources/emuXml/pluto.xml" "${CMAKE_SOURCE_DIR}/JS/scopyDefaultTests.js" "{\"connect\", \"disconnect\"}")
add_test(NAME "SwitchToolJSTest" COMMAND bash ${CMAKE_SOURCE_DIR}/JS/test.sh "${CMAKE_SOURCE_DIR}/resources/emuXml/pluto.xml" "${CMAKE_SOURCE_DIR}/JS/scopyDefaultTests.js" "switchToolTest")

0 comments on commit 7701128

Please sign in to comment.