Skip to content

Commit

Permalink
Added regmap js tests
Browse files Browse the repository at this point in the history
Signed-off-by: Alexandru Lie <[email protected]>
  • Loading branch information
liealex authored and adisuciu committed Oct 25, 2024
1 parent c81a47e commit e0c6a7e
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 1 deletion.
56 changes: 56 additions & 0 deletions plugins/regmap/js/regMapAutomatedTest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
//This import path is relative to where scopy is build
evaluateFile("../js/scopycommon.js")
evaluateFile("../plugins/regmap/js/regMapFunctions.js")


//Not working with EMU
function deviceTest() {
connect()
switchToRegMap()
readRegister("0x00")
regmap.write("0x00", "0x01")
regmap.write("0x00", "0x00")
}

function deviceTestEMU(path) {
connect()
switchToRegMap()
regmap.readInterval("0x00", "0x07")
regmap.registerDump(path)
regmap.writeFromFile(path)
}

function chageDevicesTest() {
connect()
switchToRegMap()
switchDevice("cf-ad9361-dds-core-lpc")
readRegister("0x00")
regmap.write("0x00", "0x01")
}

//Not working with EMU
function writeRegisterTest() {
connect()
switchToRegMap()
readRegister("0x00")
regmap.write("0x00", "0x01")
let readResult = readRegister("0x00")
if (readResult != "0x01") {
printToConsole("Failed to write")
exit(1)
}
}

function writeBitField(addr, val) {
connect()
switchToRegMap()
regmap.writeBitField(addr, val)
}

deviceTest()
deviceTestEMU("")
chageDevicesTest()
writeRegisterTest()
writeBitField("0x01", "0x01")
disconnect()
scopy.exit()
26 changes: 26 additions & 0 deletions plugins/regmap/js/regMapFunctions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
evaluateFile("../js/scopycommon.js")

function switchToRegMap() {
let toolSwitched = scopy.switchTool("Register map")
if (!toolSwitched) {
printToConsole("Failed to switch to Register Map")
exit(1)
}
}

function readRegister(reg) {
let result = regmap.readRegister(reg)
if (result.length === 0) {
printToConsole("Failed to read register " + reg)
exit(1)
}
return result
}

function switchDevice(devName) {
let result = regmap.setDevice(devName)
if (!result) {
printToConsole("Failed to change device " + devName)
exit(1)
}
}
2 changes: 1 addition & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ if(ENABLE_AUTOMATED_TESTS)
if(ENABLE_PLUGIN_REGMAP)
add_test(NAME "RegMapJSTests"
COMMAND bash ${CMAKE_SOURCE_DIR}/js/test.sh "${CMAKE_SOURCE_DIR}/resources/emuXml/"
"${CMAKE_SOURCE_DIR}/plugins/regmap/js/regMapFunctions.js"
"${CMAKE_SOURCE_DIR}/plugins/regmap/js/regMapAutomatedTest.js"
)
endif()

Expand Down

0 comments on commit e0c6a7e

Please sign in to comment.