Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
83be720
DEV-1242 Android HIL v1: phone tests on Shimmer3/3R, and a release gate
JongChern Oct 20, 2026
4671540
DEV-1242 HIL: fixes from the first hardware runs
JongChern Oct 20, 2026
4666dee
DEV-1242 HIL: Classic and BLE per unit, timestamp jumps, survive a lo…
JongChern Oct 20, 2026
2818f53
DEV-1242 HIL: fail on unsuccessful calls; -Report uses the gate's set…
JongChern Oct 20, 2026
8df71c3
DEV-1242 HIL: fail when timestamps give no rate or the stream goes si…
JongChern Oct 20, 2026
6aded9d
DEV-1242 HIL: a run whose report was not collected is an error
JongChern Oct 20, 2026
dd343fd
DEV-1242 HIL: a skipped scenario is not a pass
JongChern Oct 20, 2026
553e96a
DEV-1242 HIL: wait for the battery reply; keep NaN metrics; check cle…
JongChern Oct 20, 2026
ef77412
HIL: save each run's Bluetooth bytes as a replayable trace (-CaptureB…
JongChern Oct 20, 2026
24c50ac
HIL capture: the snoop log is in local time; check the mode that's in…
JongChern Oct 20, 2026
532cc8b
DEV-1251 HIL capture: per-connection CCCD filter; delete an unreadabl…
JongChern Oct 20, 2026
28aeb2b
DEV-1251 HIL capture: cite the RFCOMM length encoding
JongChern Oct 20, 2026
75136c9
DEV-1291 DEV-1275 HIL: inStream and connectReady scenarios
JongChern Oct 22, 2026
a7f524d
DEV-1291 DEV-1275 HIL: read the instruction queue without the device'…
JongChern Oct 22, 2026
89d8bf0
DEV-1291 DEV-1275 HIL: never leave a unit logging; dump threads on a …
JongChern Oct 22, 2026
78dad60
DEV-1291 DEV-1275 HIL: count inStream's log a round at a time; jumps …
JongChern Oct 22, 2026
7995348
DEV-1266 Android HIL: queueStress, to reproduce the lock-order deadlock
JongChern Oct 23, 2026
b60c9af
DEV-1306 Android HIL: samplingRates, configuring straight after a stop
JongChern Oct 23, 2026
84e97ab
Merge pull request #138 from ShimmerResearch/DEV-1306_android_hil_sam…
JongChern Oct 23, 2026
7c16b8a
Merge pull request #136 from ShimmerResearch/DEV-1266_android_hil_que…
JongChern Oct 23, 2026
eb708e3
Merge pull request #134 from ShimmerResearch/DEV-1291_android_hil_sce…
JongChern Oct 23, 2026
e067a85
Merge pull request #131 from ShimmerResearch/DEV-1251_hil_byte_capture
JongChern Oct 23, 2026
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
50 changes: 50 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
#
# If only the release job fails, "Re-run failed jobs" re-runs just that job.
#
# Hardware test gate: before releasing, run tools/hil/run-android-hil.ps1 -Report on the bench at the
# commit being released (see tools/hil/README.md). It posts the commit status
# "android-hil (driver X)". A real release refuses to build unless that status passed for this commit
# and this driver, or hil_waiver gives a Jira key (the waiver goes into the release notes). Dry runs
# only warn. The release notes say what the hardware test found.
#
# The driver is read from Shimmer-Java-Android-API's GitHub Packages with this repo's GITHUB_TOKEN.
# If that is ever refused (401/403 resolving com.shimmerresearch:shimmerdriver), add a classic token
# with read:packages as the PACKAGES_READ_TOKEN secret and it is used instead.
Expand All @@ -45,6 +51,10 @@ on:
description: 'Java API (driver) version to build against, e.g. 0.11.9_beta. Blank = newest release'
type: string
required: false
hil_waiver:
description: 'Jira key to release without a passing hardware test (HIL), e.g. DEV-1234. Blank = require one'
type: string
required: false
dry_run:
description: 'Build only; publish nothing'
type: boolean
Expand All @@ -71,6 +81,7 @@ jobs:
permissions:
contents: read
packages: read
statuses: read # the hardware test result the bench posts on the commit
env:
DRY_RUN: ${{ github.event_name != 'workflow_dispatch' || inputs.dry_run }}
# Read by the repositories in the root build.gradle to resolve the driver.
Expand All @@ -81,6 +92,7 @@ jobs:
tag: ${{ steps.version.outputs.tag }}
previous_tag: ${{ steps.version.outputs.previous_tag }}
driver: ${{ steps.version.outputs.driver }}
hil: ${{ steps.hil.outputs.hil }}
steps:
- name: Release from master only
if: env.DRY_RUN != 'true' && github.ref != 'refs/heads/master'
Expand Down Expand Up @@ -167,6 +179,38 @@ jobs:
} >> "$GITHUB_OUTPUT"
echo "Releasing $VERSION as $TAG against driver $DRIVER (master's default: ${default_driver:-none}; notes since ${PREVIOUS_TAG:-the first commit})"

# Before any building, so a missing hardware test fails the release in seconds.
- name: Check the hardware test (HIL) result
id: hil
working-directory: .
env:
GH_TOKEN: ${{ github.token }}
DRIVER: ${{ steps.version.outputs.driver }}
WAIVER: ${{ inputs.hil_waiver }}
run: |
context="android-hil (driver $DRIVER)"
if [ -n "$WAIVER" ] && ! [[ "$WAIVER" =~ ^[A-Z][A-Z0-9]+-[0-9]+$ ]]; then
echo "::error::hil_waiver must be a Jira key such as DEV-1234, not '$WAIVER'."
exit 1
fi
# Newest first: the latest result for this context on this exact commit decides.
line=$(gh api "repos/$GITHUB_REPOSITORY/commits/$GITHUB_SHA/statuses" --paginate \
--jq '.[] | [.context, .state, .description] | @tsv' | awk -F'\t' -v c="$context" '$1 == c { print; exit }')
state=$(printf '%s' "$line" | cut -f2)
description=$(printf '%s' "$line" | cut -f3)
if [ "$state" = success ]; then
echo "Hardware test passed on $GITHUB_SHA with driver $DRIVER: $description"
echo "hil=Tested on hardware before release (driver $DRIVER): $description." >> "$GITHUB_OUTPUT"
elif [ -n "$WAIVER" ]; then
echo "::warning::No passing '$context' on $GITHUB_SHA (found: ${state:-none}); released under waiver $WAIVER."
echo "hil=Released without a passing hardware test (HIL), waived under $WAIVER." >> "$GITHUB_OUTPUT"
elif [ "$DRY_RUN" = true ]; then
echo "::warning::No passing '$context' on $GITHUB_SHA (found: ${state:-none}). A real release would stop here."
else
echo "::error::No passing '$context' on $GITHUB_SHA (found: ${state:-none}${description:+: $description}). On the bench, at this commit, run: tools/hil/run-android-hil.ps1 -Report -DriverVersion $DRIVER. Then run this workflow again, or give a Jira key in hil_waiver."
exit 1
fi

# AGP 8 needs JDK 17.
- name: Set up JDK 17
uses: actions/setup-java@cf277c60eb25467037889841efdb72551f06f6c3 # v4.9.1
Expand Down Expand Up @@ -271,6 +315,7 @@ jobs:
TAG: ${{ needs.build.outputs.tag }}
PREVIOUS_TAG: ${{ needs.build.outputs.previous_tag }}
DRIVER: ${{ needs.build.outputs.driver }}
HIL: ${{ needs.build.outputs.hil }}
steps:
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
Expand All @@ -290,6 +335,10 @@ jobs:
# The driver's JNA is desktop-only; its two jars clash on META-INF/AL2.0 in an Android app.
echo "Exclude \`net.java.dev.jna\` from both, or the app fails packaging with \"2 files found with path 'META-INF/AL2.0'\". The exclusions this library builds with are in [ShimmerAndroidInstrumentDriver/build.gradle]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/blob/$TAG/ShimmerAndroidInstrumentDriver/build.gradle)."
echo
if [ -n "$HIL" ]; then
echo "$HIL"
echo
fi
gh api "repos/$GITHUB_REPOSITORY/releases/generate-notes" "${args[@]}" --jq .body
} > notes.md
gh release create "$TAG" release-assets/* \
Expand All @@ -302,4 +351,5 @@ jobs:
echo "- Release: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/releases/tag/$TAG"
echo "- Package: com.shimmerresearch:shimmerandroidinstrumentdriver:$VERSION"
echo "- Built against driver $DRIVER"
echo "- ${HIL:-No hardware test result}"
} >> "$GITHUB_STEP_SUMMARY"
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,8 @@ lint/tmp/
gradle.properties
ShimmerAndroidInstrumentDriver/.idea/jarRepositories.xml
ShimmerAndroidInstrumentDriver/.idea/gradle.xml

# Android HIL (tools/hil): the local rig file and run output
tools/hil/rig-android.json
tools/hil/out/
tools/hil/__pycache__/
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,6 @@ compile 'ShimmerAndroidInstrumentDriver:ShimmerAndroidInstrumentDriver:3.0.69Bet




# Hardware tests
The Android API can be tested on a phone against real Shimmer3 and Shimmer3R units with one command: see [tools/hil/README.md](tools/hil/README.md).
1 change: 1 addition & 0 deletions ShimmerAndroidInstrumentDriver/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ include ':shimmer3DOrientationExample', ':shimmerConnectionTest'
//project (":ShimmerAdvanceLibrary").projectDir = new File("../../ShimmerAdvanceAPI/ShimmerAdvanceLibrary")
include ':multiverisenseblebasicexample' , ':shimmer3BLEBasicExample'
include ':shimmerspeedtest'
include ':shimmerHilTest'
52 changes: 52 additions & 0 deletions ShimmerAndroidInstrumentDriver/shimmerHilTest/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Hardware-in-the-loop (HIL) tests of the Android API on a USB-attached phone against real
// Shimmer3 / Shimmer3R units. The tests are in src/androidTest; this app only hosts them. Run them
// with tools/hil/run-android-hil.ps1 (see tools/hil/README.md).
//
// Which Android API is tested:
// default the ShimmerAndroidInstrumentDriver source in this checkout
// -PandroidApiVersion=3.2.10_beta the published .aar, as a customer app gets it
// Which driver: -PdriverVersion, read by the root build.gradle like every other module.
apply plugin: 'com.android.application'

def androidApiVersion = findProperty('androidApiVersion')

android {
namespace 'com.shimmerresearch.hiltest'
compileSdkVersion 34

defaultConfig {
applicationId "com.shimmerresearch.hiltest"
minSdkVersion 21
targetSdkVersion 34
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

packagingOptions {
resources {
excludes += ['META-INF/INDEX.LIST', 'META-INF/DEPENDENCIES', 'META-INF/LICENSE',
'META-INF/LICENSE.txt', 'META-INF/license.txt', 'META-INF/NOTICE',
'META-INF/NOTICE.txt', 'META-INF/notice.txt', 'META-INF/ASL2.0']
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {
if (androidApiVersion) {
implementation(group: 'com.shimmerresearch', name: 'shimmerandroidinstrumentdriver', version: androidApiVersion, ext: 'aar')
} else {
implementation project(':ShimmerAndroidInstrumentDriver')
}
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test:runner:1.5.2'
androidTestImplementation 'androidx.test:rules:1.5.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'junit:junit:4.13.2'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
package com.shimmerresearch.hiltest;

import android.content.Context;
import android.os.Bundle;
import android.util.Log;

import org.json.JSONArray;
import org.json.JSONObject;

import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;

/**
* Everything one scenario run found, written as JSON (plus a CSV of samples) to the app's
* external files dir, hil/, for tools/hil/run-android-hil.ps1 to pull.
*/
final class HilReport {

private final Context context;
private final String scenario;
private final String transport;
private final String mac;
private final JSONObject json = new JSONObject();
private final List<String> failures = new ArrayList<>();
private List<StreamAnalysis.Sample> samples;

HilReport(Context context, String scenario, String transport, String mac, Bundle args) throws Exception {
this.context = context;
this.scenario = scenario;
this.transport = transport;
this.mac = mac;
json.put("scenario", scenario);
json.put("transport", transport);
json.put("mac", mac);
json.put("started", new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ", Locale.ROOT).format(new Date()));
JSONObject a = new JSONObject();
for (String key : args.keySet()) {
a.put(key, String.valueOf(args.get(key)));
}
json.put("args", a);
}

/** org.json refuses NaN and infinities, which a failing run is the likeliest to produce; store null. */
private static Object num(double v) {
return Double.isNaN(v) || Double.isInfinite(v) ? JSONObject.NULL : v;
}

void put(String key, Object value) {
try {
json.put(key, value instanceof Double || value instanceof Float ? num(((Number) value).doubleValue()) : value);
} catch (Exception e) {
Log.w(ShimmerSession.TAG, "report: " + key + ": " + e);
}
}

void putStream(String key, StreamAnalysis a) {
try {
JSONObject o = new JSONObject();
o.put("received", a.received);
o.put("missing", a.missing);
o.put("lossPercent", num(a.lossPercent()));
o.put("nonIncreasing", a.nonIncreasing);
o.put("timestampJumps", a.timestampJumps.size());
o.put("effectiveRateHz", num(a.effectiveRateHz));
o.put("accelMagnitudeMean", num(a.accelMagnitudeMean));
o.put("accelMagnitudeStd", num(a.accelMagnitudeStd));
o.put("gaps", a.gaps.size());
json.put(key, o);
} catch (Exception e) {
Log.w(ShimmerSession.TAG, "report: " + key + ": " + e);
}
}

/** Every gap, with when it arrived, so a loss can be matched to what the test was doing. */
void putGaps(StreamAnalysis a) {
try {
JSONArray gaps = new JSONArray();
for (StreamAnalysis.Gap g : a.gaps) {
JSONObject o = new JSONObject();
o.put("afterReceivedMs", Math.round(g.afterReceivedMs));
o.put("afterTimestampMs", num(g.afterTimestampMs));
o.put("missing", g.missing);
gaps.put(o);
}
json.put("gapList", gaps);
JSONArray jumps = new JSONArray();
for (StreamAnalysis.Gap g : a.timestampJumps) {
JSONObject o = new JSONObject();
o.put("afterReceivedMs", Math.round(g.afterReceivedMs));
o.put("afterTimestampMs", num(g.afterTimestampMs));
o.put("periodsAhead", g.missing + 1);
jumps.put(o);
}
json.put("timestampJumpList", jumps);
} catch (Exception e) {
Log.w(ShimmerSession.TAG, "report: gapList: " + e);
}
}

void samples(List<StreamAnalysis.Sample> samples) {
this.samples = samples;
}

/** Records a failed check; the test fails at the end with every one of them. */
void check(boolean ok, String failure) {
if (!ok) {
failures.add(failure);
Log.e(ShimmerSession.TAG, scenario + " " + transport + " " + mac + " FAIL: " + failure);
}
}

List<String> failures() {
return failures;
}

void write(List<String> events) {
try {
json.put("passed", failures.isEmpty());
json.put("failures", new JSONArray(failures));
json.put("events", new JSONArray(events));
File dir = new File(context.getExternalFilesDir(null), "hil");
if (!dir.exists() && !dir.mkdirs()) {
throw new IllegalStateException("cannot create " + dir);
}
String base = scenario + "_" + transport + "_" + mac.replace(":", "") + "_"
+ new SimpleDateFormat("yyyyMMdd-HHmmss", Locale.ROOT).format(new Date());
try (Writer w = new OutputStreamWriter(new FileOutputStream(new File(dir, base + ".json")), StandardCharsets.UTF_8)) {
w.write(json.toString(2));
}
if (samples != null) {
try (Writer w = new OutputStreamWriter(new FileOutputStream(new File(dir, base + ".csv")), StandardCharsets.UTF_8)) {
w.write("received_ms,timestamp_ms,accel_x,accel_y,accel_z\n");
for (StreamAnalysis.Sample s : samples) {
w.write(String.format(Locale.ROOT, "%.0f,%.3f,%.4f,%.4f,%.4f\n",
s.receivedMs, s.timestampMs, s.accelX, s.accelY, s.accelZ));
}
}
}
Log.i(ShimmerSession.TAG, "report written: " + new File(dir, base + ".json"));
} catch (Exception e) {
Log.e(ShimmerSession.TAG, "could not write report: " + e);
}
}
}
Loading
Loading