Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,11 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/Scopy.app/Contents/MacOS")
endif()

if(ENABLE_SCOPYJS)
message(STATUS "JS tests enabled - copying js/ to build directory")
file(COPY ${CMAKE_SOURCE_DIR}/js/ DESTINATION ${CMAKE_BINARY_DIR}/js)
endif()

set(SCOPY_DEPENDENCIES ${IIO_LIBRARIES})

if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
Expand Down
22 changes: 13 additions & 9 deletions js/testAutomations/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,41 @@

## Running Scripts — Path Requirements

All test scripts use `evaluateFile()` with paths **relative to the Scopy build directory**. The `evaluateFile()` function resolves paths against the current working directory (CWD), not the script file's location. This means **you must always run Scopy from the `build/` directory**:
All test scripts use `evaluateFile()` with paths **relative to the Scopy build directory**. The `evaluateFile()` function resolves paths against the current working directory (CWD), not the script file's location.

Enable the `JS_TESTS_ENABLED` CMake option to copy the `js/` directory into the build directory, then run tests directly from the build directory:

```bash
cd scopy/build/
./scopy --script ../js/testAutomations/<path-to-test>.js
cmake .. -DENABLE_SCOPYJS=ON -DJS_TESTS_ENABLED=ON
make -j$(nproc)
./scopy --script js/testAutomations/<path-to-test>.js
```

For example:
```bash
cd scopy/build/
./scopy --script ../js/testAutomations/core/pluginLoadTests.js
./scopy --script ../js/testAutomations/m2k/voltmeter/voltmeter_dc_loopback.js
./scopy --script js/testAutomations/core/pluginLoadTests.js
./scopy --script js/testAutomations/m2k/voltmeter/voltmeter_dc_loopback.js
```

Running from any other directory will cause `evaluateFile()` calls inside the scripts to fail, since they all load the shared test framework via:
All test scripts load the shared test framework via:
```javascript
evaluateFile("../js/testAutomations/common/testFramework.js");
evaluateFile("js/testAutomations/common/testFramework.js");
```
This path only resolves correctly when CWD is `build/` (i.e., `build/../js/testAutomations/...`).
This path resolves correctly from any build directory when `JS_TESTS_ENABLED=ON` is set.

---

## Requirements

- **Scopy** built with `-DENABLE_SCOPYJS=ON`
- **Scopy** built with `-DENABLE_SCOPYJS=ON -DJS_TESTS_ENABLED=ON`
- **iio-emu** for emulator-based tests (`iio-emu adalm2000`, `iio-emu generic`, etc.)
- **ADALM2000 hardware** for M2K loopback tests requiring real signal paths

```bash
cd scopy/build/
cmake .. -DENABLE_SCOPYJS=ON
cmake .. -DENABLE_SCOPYJS=ON -DJS_TESTS_ENABLED=ON
make -j$(nproc)
```

Expand Down
2 changes: 1 addition & 1 deletion js/testAutomations/ad9084/ad9084DocTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
// Tests: TST.AD9084.CHANNEL_CONFIGURATION, TST.AD9084.DISABLE_ENABLE_RX_TX_TABS

// Load test framework
evaluateFile("../js/testAutomations/common/testFramework.js");
evaluateFile("js/testAutomations/common/testFramework.js");

// Test Suite
TestFramework.init("AD9084 Documentation Tests");
Expand Down
2 changes: 1 addition & 1 deletion js/testAutomations/ad9084/ad9084Tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
// Runs all API tests: Connection, Tools, RX Chain, TX Chain, Widget Access, Utility

// Load test framework
evaluateFile("../js/testAutomations/common/testFramework.js");
evaluateFile("js/testAutomations/common/testFramework.js");

// Test Suite: AD9084 Plugin Tests
TestFramework.init("AD9084 Plugin Tests");
Expand Down
2 changes: 1 addition & 1 deletion js/testAutomations/ad9084/ad9084VisualTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
// ============================================================================

// Load test framework
evaluateFile("../js/testAutomations/common/testFramework.js");
evaluateFile("js/testAutomations/common/testFramework.js");

// Test Suite
TestFramework.init("AD9084 Visual Validation Tests");
Expand Down
2 changes: 1 addition & 1 deletion js/testAutomations/ad936x/ad936xAdvancedTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
// Runs all API tests for the AD936X Advanced debug attributes

// Load test framework
evaluateFile("../js/testAutomations/common/testFramework.js");
evaluateFile("js/testAutomations/common/testFramework.js");

// Test Suite: AD936x Advanced Plugin Tests
TestFramework.init("AD936x Advanced Plugin Tests");
Expand Down
2 changes: 1 addition & 1 deletion js/testAutomations/ad936x/ad936xDocTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
// TST.AD936X_ADVANCED.PLUGIN_DETECTION_AND_DISPLAY

// Load test framework
evaluateFile("../js/testAutomations/common/testFramework.js");
evaluateFile("js/testAutomations/common/testFramework.js");

// Test Suite
TestFramework.init("AD936x Documentation Tests");
Expand Down
2 changes: 1 addition & 1 deletion js/testAutomations/ad936x/ad936xTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
// Runs all API tests: Connection, Global Settings, RX Chain, TX Chain, Widget Access, Utility

// Load test framework
evaluateFile("../js/testAutomations/common/testFramework.js");
evaluateFile("js/testAutomations/common/testFramework.js");

// Test Suite: AD936x Plugin Tests
TestFramework.init("AD936x Plugin Tests");
Expand Down
2 changes: 1 addition & 1 deletion js/testAutomations/ad936x/ad936xVisualTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
// ============================================================================

// Load test framework
evaluateFile("../js/testAutomations/common/testFramework.js");
evaluateFile("js/testAutomations/common/testFramework.js");

// Test Suite
TestFramework.init("AD936x Visual Validation Tests");
Expand Down
2 changes: 1 addition & 1 deletion js/testAutomations/ad936x/fmcomms5AdvancedTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
// Runs all API tests for the FMCOMMS5 Advanced debug attributes

// Load test framework
evaluateFile("../js/testAutomations/common/testFramework.js");
evaluateFile("js/testAutomations/common/testFramework.js");

// Test Suite: FMCOMMS5 Advanced Plugin Tests
TestFramework.init("FMCOMMS5 Advanced Plugin Tests");
Expand Down
2 changes: 1 addition & 1 deletion js/testAutomations/ad936x/fmcomms5DocTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
// LO frequencies are per-device (device 0 and device 1)

// Load test framework
evaluateFile("../js/testAutomations/common/testFramework.js");
evaluateFile("js/testAutomations/common/testFramework.js");

// Test Suite
TestFramework.init("FMCOMMS5 Documentation Tests");
Expand Down
2 changes: 1 addition & 1 deletion js/testAutomations/ad936x/fmcomms5Tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
// Runs all API tests: Global Settings, RX Chain, TX Chain, Per-Channel, LO, Widget Access, Utility

// Load test framework
evaluateFile("../js/testAutomations/common/testFramework.js");
evaluateFile("js/testAutomations/common/testFramework.js");

// Test Suite: FMCOMMS5 Plugin Tests
TestFramework.init("FMCOMMS5 Plugin Tests");
Expand Down
2 changes: 1 addition & 1 deletion js/testAutomations/ad936x/fmcomms5VisualTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
// ============================================================================

// Load test framework
evaluateFile("../js/testAutomations/common/testFramework.js");
evaluateFile("js/testAutomations/common/testFramework.js");

// Test Suite
TestFramework.init("FMCOMMS5 Visual Validation Tests");
Expand Down
2 changes: 1 addition & 1 deletion js/testAutomations/adrv9002/adrv9002DocTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
// Skipped: TST.ADRV9002.CONTROLS.DEVICE_DRIVER_API (no API for version string)

// Load test framework
evaluateFile("../js/testAutomations/common/testFramework.js");
evaluateFile("js/testAutomations/common/testFramework.js");

// Test Suite
TestFramework.init("ADRV9002 Documentation Tests");
Expand Down
2 changes: 1 addition & 1 deletion js/testAutomations/adrv9002/adrv9002Tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
// Runs all API tests: Connection, Global, RX Chain, RX Tracking, TX Chain, TX Tracking, ORX, Widget Access, Utility

// Load test framework
evaluateFile("../js/testAutomations/common/testFramework.js");
evaluateFile("js/testAutomations/common/testFramework.js");

// Test Suite: ADRV9002 Plugin Tests
TestFramework.init("ADRV9002 Plugin Tests");
Expand Down
2 changes: 1 addition & 1 deletion js/testAutomations/adrv9002/adrv9002VisualTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
// ============================================================================

// Load test framework
evaluateFile("../js/testAutomations/common/testFramework.js");
evaluateFile("js/testAutomations/common/testFramework.js");

// Test Suite
TestFramework.init("ADRV9002 Visual Validation Tests");
Expand Down
15 changes: 15 additions & 0 deletions js/testAutomations/common/testFramework.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,21 @@ var TestFramework = {
return this.failedTests === 0 ? 0 : 1;
},

// Supervised visual check - prompts user for pass/fail input
// Use this in VisualTests when validation requires human observation.
// Blocks until the user types 'y' (pass) or 'n' (fail).
supervisedCheck: function(description) {
printToConsole(" SUPERVISED CHECK: " + description);
var response = readFromConsole(" >> Pass? (y/n): ");
var passed = (response.trim().toLowerCase() === "y");
if (passed) {
printToConsole(" PASS: Confirmed by user");
} else {
printToConsole(" FAIL: Rejected by user");
}
return passed;
},

// Save test results to file
saveResults: function(filePath) {
try {
Expand Down
2 changes: 1 addition & 1 deletion js/testAutomations/core/connectionTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
// TST.DEV.SELECT_TOOL, TST.DEV.ADD_ORDER, TST.DEV.MULTI_CONN, TST.DEV.RM_MULTI

// Load test framework
evaluateFile("../js/testAutomations/common/testFramework.js");
evaluateFile("js/testAutomations/common/testFramework.js");

// Test Suite: Connection Tests
TestFramework.init("Connection Lifecycle Tests");
Expand Down
2 changes: 1 addition & 1 deletion js/testAutomations/core/emulatorTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
// Prerequisite: iio-emu must be running externally for most tests

// Load test framework
evaluateFile("../js/testAutomations/common/testFramework.js");
evaluateFile("js/testAutomations/common/testFramework.js");

// Test Suite: Emulator Tests
TestFramework.init("Emulator Connection Tests");
Expand Down
2 changes: 1 addition & 1 deletion js/testAutomations/core/pluginLoadTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
// 6. Disconnects and cleans up

// Load test framework
evaluateFile("../js/testAutomations/common/testFramework.js");
evaluateFile("js/testAutomations/common/testFramework.js");

// Test Suite: Plugin Load Tests
TestFramework.init("Plugin Load Detection Tests");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
// ============================================================================

// Load test framework
evaluateFile("../js/testAutomations/common/testFramework.js");
evaluateFile("js/testAutomations/common/testFramework.js");

// Helper function to parse newline-separated string into array
function parseNewlineSeparatedString(str) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
// ============================================================================

// Load test framework
evaluateFile("../js/testAutomations/common/testFramework.js");
evaluateFile("js/testAutomations/common/testFramework.js");

// Helper function to parse newline-separated string into array
function parseNewlineSeparatedString(str) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
// Tests: TST.DBG.EXPLR.LOAD, TST.DBG.EXPLR.NAV, TST.DBG.EXPLR.FILTER, TST.DBG.EXPLR.WATCH, TST.DBG.EXPLR.READ_ALL, TST.DBG.EXPLR.LOG, TST.DBG.CODEGEN

// Load test framework
evaluateFile("../js/testAutomations/common/testFramework.js");
evaluateFile("js/testAutomations/common/testFramework.js");

// Test Suite: Debugger Tests
TestFramework.init("Debugger Plugin Tests");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
// Based on TST.REGMAP.* test specifications

// Load test framework
evaluateFile("../js/testAutomations/common/testFramework.js");
evaluateFile("js/testAutomations/common/testFramework.js");

// Global wait time configuration
// Set to 1000 for normal testing, can be increased for external observation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
// ============================================================================

// Load test framework
evaluateFile("../js/testAutomations/common/testFramework.js");
evaluateFile("js/testAutomations/common/testFramework.js");

// Test Suite
TestFramework.init("Register Map Visual Validation Tests");
Expand Down
2 changes: 1 addition & 1 deletion js/testAutomations/m2k/digitalIO/dio_loopback.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
// mode cannot be set from JS. Group test simulates group behavior using
// individual pin operations.

evaluateFile("../js/testAutomations/common/testFramework.js");
evaluateFile("js/testAutomations/common/testFramework.js");

var waitTime = 1000;

Expand Down
2 changes: 1 addition & 1 deletion js/testAutomations/m2k/digitalIO/dio_voltmeter.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
// Step 10 (reversed: DIO 8→1+, DIO 1→V+) requires different wiring
// and is in dio_voltmeter_reversed.js.

evaluateFile("../js/testAutomations/common/testFramework.js");
evaluateFile("js/testAutomations/common/testFramework.js");

var waitTime = 1000;

Expand Down
2 changes: 1 addition & 1 deletion js/testAutomations/m2k/digitalIO/dio_voltmeter_reversed.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
// NOTE: No DIO loopback wires. DIO 8 and DIO 1 are each connected
// to separate instruments (voltmeter and power supply).

evaluateFile("../js/testAutomations/common/testFramework.js");
evaluateFile("js/testAutomations/common/testFramework.js");

var waitTime = 1000;

Expand Down
2 changes: 1 addition & 1 deletion js/testAutomations/m2k/oscilloscope/osc_siggen_loopback.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
// - Known C++ bug: setCursorH2 uses getHBar1() instead of getHBar2()
// - Known C++ bug: setTriggerSource has guard idx > 0, cannot set to index 0

evaluateFile("../js/testAutomations/common/testFramework.js");
evaluateFile("js/testAutomations/common/testFramework.js");

TestFramework.init("Oscilloscope + Signal Generator Loopback Tests");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
// - power.sync = false --> independent mode, power.sync = true --> tracking mode
// - power.dac2_value can only be set when sync = false (independent mode)

evaluateFile("../js/testAutomations/common/testFramework.js");
evaluateFile("js/testAutomations/common/testFramework.js");

TestFramework.init("Power Supply + Voltmeter Loopback Tests");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
// Based on TST.M2K.SG.* test specifications

// Load test framework
evaluateFile("../js/testAutomations/common/testFramework.js");
evaluateFile("js/testAutomations/common/testFramework.js");

// Test Suite: Signal Generator + Oscilloscope Integration Tests
TestFramework.init("Signal Generator + Oscilloscope Tests");
Expand Down
2 changes: 1 addition & 1 deletion js/testAutomations/m2k/spectrumAnalyzer/sa_loopback.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
// - Scope CH2+ → W2 (Signal Generator Output 2)
// - Scope CH2- → GND

evaluateFile("../js/testAutomations/common/testFramework.js");
evaluateFile("js/testAutomations/common/testFramework.js");

TestFramework.init("Spectrum Analyzer Loopback Tests");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
//
// Differential measurement: Ch1 measures V+ minus V-

evaluateFile("../js/testAutomations/common/testFramework.js");
evaluateFile("js/testAutomations/common/testFramework.js");

TestFramework.init("Voltmeter DC Differential Tests");

Expand Down
2 changes: 1 addition & 1 deletion js/testAutomations/m2k/voltmeter/voltmeter_dc_loopback.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
//
// Ch1 measures V+ (positive), Ch2 measures V- (negative)

evaluateFile("../js/testAutomations/common/testFramework.js");
evaluateFile("js/testAutomations/common/testFramework.js");

TestFramework.init("Voltmeter DC Loopback Tests");

Expand Down
2 changes: 1 addition & 1 deletion js/testAutomations/m2k/voltmeter/voltmeter_dc_reversed.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
//
// Reversed loopback. Ch1 measures V- (negative), Ch2 measures V+ (positive).

evaluateFile("../js/testAutomations/common/testFramework.js");
evaluateFile("js/testAutomations/common/testFramework.js");

TestFramework.init("Voltmeter DC Reversed Polarity Tests");

Expand Down
2 changes: 1 addition & 1 deletion js/testAutomations/pqm/pqmTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
// Runs all instrument tests: RMS, Harmonics, Waveform, Settings

// Load test framework
evaluateFile("../js/testAutomations/common/testFramework.js");
evaluateFile("js/testAutomations/common/testFramework.js");

// Test Suite: PQM Plugin Complete Tests
TestFramework.init("PQM Plugin Complete Tests");
Expand Down
2 changes: 1 addition & 1 deletion js/testAutomations/swiot/swiotSupervisedTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
// Based on test documentation from docs/tests/plugins/swiot1l/swiot1l_tests.rst

// Load test framework
evaluateFile("../js/testAutomations/common/testFramework.js");
evaluateFile("js/testAutomations/common/testFramework.js");

// Test Suite: SWIOT Supervised Tests
TestFramework.init("SWIOT Plugin Supervised Tests");
Expand Down
2 changes: 1 addition & 1 deletion js/testAutomations/swiot/swiotTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
// Based on test documentation from docs/tests/plugins/swiot1l/swiot1l_tests.rst

// Load test framework
evaluateFile("../js/testAutomations/common/testFramework.js");
evaluateFile("js/testAutomations/common/testFramework.js");

// Test Suite: SWIOT Plugin Complete Tests
TestFramework.init("SWIOT Plugin Complete Tests");
Expand Down
Loading