Skip to content

Commit

Permalink
scopy first test
Browse files Browse the repository at this point in the history
  • Loading branch information
IonutMuthi committed Jul 10, 2024
1 parent fac1121 commit e7f94f0
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 0 deletions.
20 changes: 20 additions & 0 deletions JS/scopyDefaultTests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//This import paht is relative to where scopy is build
importFileContent("../JS/scpyDefaultJsFunctions.js")

function connectionTest(){
printToConsole("TEST CONNECTION")
connect()
disconnect()
}

function switchToolTest(){
printToConsole("TEST SWITHC TOOL")
connect()
scopy.switchTool("Time")
scopy.switchTool("DataLogger 0")
scopy.switchTool("Debugger")
disconnect()
}

connectionTest()
switchToolTest()
13 changes: 13 additions & 0 deletions JS/scpyDefaultJsFunctions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
function connect(){
//TEST WITH EMU
var deviceID = scopy.addDevice("", "ip:127.0.0.0")
//CONNECT TO DEVICE
scopy.connectDevice(deviceID)
msleep(1000)
}

function disconnect(){
//DISCONNECT FROM DEVICE
scopy.disconnectDevice()
exit(0)
}
29 changes: 29 additions & 0 deletions JS/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#! /bin/bash
# set -xe
# 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
echo "############# EMU PATH IS " $1;
cd $1
iio-emu generic *.xml &
fi
fi

# run scopy functions of provided script
if [ ! -z $2 ]; then
cd $scopyBuildDir
./scopy --script=$2
fi

if emu was started by this script stop emu
if [ "$isEmuRunning" = FALSE ]; then
#stop emu
killall -9 iio-emu
fi

4 changes: 4 additions & 0 deletions resources/emuXml/pluto.xml

Large diffs are not rendered by default.

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)

add_test(NAME "ScopyDefaultJSTests" COMMAND bash ${CMAKE_SOURCE_DIR}/JS/test.sh "${CMAKE_SOURCE_DIR}/resources/emuXml/"
"${CMAKE_SOURCE_DIR}/JS/scopyDefaultTests.js"
)

0 comments on commit e7f94f0

Please sign in to comment.