Cuica

CLI Application
CLI ApplicationBasic Usage

Basic Usage

Basic usage of the CLI application

Authentication

The first time the cuica CLI application is run, the config subcommand is used to configure the initial connection parameters:

$ cuica config --reset
Config file not found, please enter the following details:
◦ Hostname: my-cuica
◦ Have Root CA (no): yes
◦ Root CA Path: /home/you/cert-bundle.pem
◦ Username: someone
◦ Password: 
Connected to cuica, version: 1.2.3

These configuration settings are stored in the ~/.cufig file by default. When using the interactive configuration method, the cuica CLI application will log into the Cuica using the provided credentials and obtain a one-hour token. To use a longer-lasting token, use the web interface to generate one and store that in the configuration. Note that neither the username nor the password is stored in the cufig file.

Tokens created by cuica config default to 1 hour expiration

Scripting

For non-interactive use, e.g. from a CI/CD pipeline, the following environment variables can be used to override the values found in the cufig file.

  • CUICA_API_TOKEN - API token generated manually via web interface
  • CUICA_API_HOSTNAME - Default hostname of the Cuica
  • CUICA_CONFIG_PATH - Where the configuration data will be stored (default: ~/.cufig)

Usage

The cuica CLI application has integrated help:

$ cuica help

Since it's in its early stages, the Cuica CLI Application and its subcommands closely follow the REST API, so refer to that for additional information.

$ cuica system info
{
  "version": "0.0.0",
  "buildVersion": "82e1830",
  "lastCommitTime": "2024-10-26T00:37:38-04:00",
  "serialNumber": "CUIPRF-DEV1"
}

Further Examples

Read Current GPIO State

This command reads the current GPIO state:

$ cuica fixture get-gpio --index 0
{
  "state": true
}

Show Test Script Info

These commands retrieve all the Test Scripts in the Test Script Bank, and then retrieves the details of one of them:

$ ./cuica script get --all
{
  "testScriptUuids": [
    "3d1b8091-2707-4d1b-85f3-6d697d418bae",
    "a57dfe5a-8e73-485e-8e77-b38b75dc7787",
    "afdc0ed9-7b40-4ad1-85a9-4bc8313170a8"
  ]
}
$ cuica script get 3d1b8091-2707-4d1b-85f3-6d697d418bae -l
{
  "metadata": {
    "label": "My Script",
    "version": "v1.0",
    "tags": [],
    "readOnly": {
      "uuid": "3d1b8091-2707-4d1b-85f3-6d697d418bae",
      "format": "python",
      "modificationCount": 0,
      "addRequestUuid": "19c1f6e4-06d6-4995-97fa-4c9ec1c6b88f",
      "addedByTestSuiteUuid": null,
      "originalFilename": null,
      "currentSha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
      "originalSha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
      "creationTime": "2024-10-29T23:05:15.125712613Z"
    },
    "extendedReadOnly": {
      "size": 3987,
      "sha256": "721edab982ece14c541199b2b30c843d16d3b992baa2ba1ca1efa36b18f7ea01",
      "md5": "383b141e899195f6c498e1ca4f194c7a",
      "sha1": "743e68e07297301a2964e8e1100d8c1fdc650103",
      "crc32": "b6550ebc",
      "checkResults": {
        "errorString": "",
        "errorLine": 0,
        "bytesUsed": 2790,
        "bytesTotal": 16384
      }
    }
  }
}

Run Test Script One-Liner

This illustrates running a Test Script on the Fixture right from the command-line. This lights the debug LED on the Squeak Board:

$ cuica script run --string "from machine import Pin; Pin(2, Pin.OUT).value(1)"
{
  "TestScriptRunCompleted": {
    "requestUuid": "3594251d-39f6-4acd-8094-9d77d3df300d",
    "eventType": "testScriptRunCompleted",
    "setupScriptUuid": null,
    "testCaseScriptUuid": null,
    "setupScriptRunUuid": null,
    "testCaseScriptRunUuid": null,
    "testScriptRunResult": "pass",
    "stdout": ""
  }
}
*Sets LED on Squeak Board

Run Test Script File

This example shows running a Test Script on the Fixture directly from a file containing a divide-by-zero error:

divide_by_zero.py
1/0
$ cuica script run --file divide_by_zero.py 
{
  "TestScriptRunCompleted": {
    "requestUuid": "cd73f175-e591-42dd-b609-bc8487bd00be",
    "eventType": "testScriptRunCompleted",
    "setupScriptUuid": null,
    "testCaseScriptUuid": null,
    "setupScriptRunUuid": null,
    "testCaseScriptRunUuid": null,
    "testScriptRunResult": "failException",
    "stdout": "FATAL: uncaught exception 20011b70\nTraceback (most recent call last):\n  File \"(unnamed script)\", line 1, in <module>\nZeroDivisionError: divide by zero\n"
  }
}
Copyright © Uatha LLC. All rights reserved.