-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added CI. Moved script to new 'scripts/' directory.
- Loading branch information
1 parent
7825af8
commit 173f0d4
Showing
2 changed files
with
194 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
on: [push, pull_request] | ||
|
||
name: Continuous integration | ||
|
||
jobs: | ||
check: | ||
name: Check | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
rust: | ||
- stable | ||
- 1.63.0 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: minimal | ||
toolchain: ${{ matrix.rust }} | ||
override: true | ||
- uses: actions-rs/cargo@v1 | ||
with: | ||
command: check | ||
args: --all-targets | ||
|
||
# The tests currently won't work without the 'industrialio' and 'iio_dummy' | ||
# modules, loaded into the kernel. | ||
# Perhaps split out a default set of tests that don't hit the kernel and | ||
# enable this. | ||
|
||
# test: | ||
# name: Test Suite | ||
# runs-on: ubuntu-latest | ||
# strategy: | ||
# matrix: | ||
# rust: | ||
# - stable | ||
# - 1.63.0 | ||
# steps: | ||
# - uses: actions/checkout@v2 | ||
# - uses: actions-rs/toolchain@v1 | ||
# with: | ||
# profile: minimal | ||
# toolchain: ${{ matrix.rust }} | ||
# override: true | ||
# - uses: actions-rs/cargo@v1 | ||
# with: | ||
# command: test | ||
|
||
fmt: | ||
name: Rustfmt | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
rust: | ||
- stable | ||
- 1.63.0 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: minimal | ||
toolchain: ${{ matrix.rust }} | ||
override: true | ||
- run: rustup component add rustfmt | ||
- uses: actions-rs/cargo@v1 | ||
with: | ||
command: fmt | ||
args: --all -- --check | ||
|
||
clippy: | ||
name: Clippy | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
rust: | ||
- stable | ||
- 1.63.0 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: minimal | ||
toolchain: ${{ matrix.rust }} | ||
override: true | ||
- run: rustup component add clippy | ||
- uses: actions-rs/cargo@v1 | ||
with: | ||
command: clippy | ||
args: -- -D warnings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
#!/bin/bash | ||
# | ||
# load_dummy.sh | ||
# | ||
# Loads the required IIO kernel modules and then creates a dummy device | ||
# and one hrtimer. | ||
# | ||
# This is useful for application testing and unit testing of the library. | ||
# | ||
# The required IIO drivers must be comiled for the kernel as loadable modules. | ||
# This should be the case for Ubuntu 18.04 and Mint 19. Your mileage may vary. | ||
# | ||
|
||
# Names of the device and timer that will be created | ||
IIO_DEV_NAME=dummydev | ||
IIO_TIMER_NAME=timer0 | ||
|
||
# ----- Must have root privleges to run this script ----- | ||
|
||
if (( $EUID != 0 )); then | ||
echo "This script must be run as root" | ||
exit 1 | ||
fi | ||
|
||
# ----- Load the kernel module(s) ----- | ||
|
||
DUMMY_LOADED=$(lsmod | grep ^iio_dummy) | ||
|
||
if [ -n "${DUMMY_LOADED}" ]; then | ||
printf "IIO dummy module already loaded.\n" | ||
else | ||
if ! modprobe iio_dummy ; then | ||
printf "Unable to load load the IIO dummy module.\n" | ||
exit 1 | ||
fi | ||
printf "IIO dummy module loaded.\n" | ||
fi | ||
|
||
HRTIMER_LOADED=$(lsmod | grep ^iio_trig_hrtimer) | ||
|
||
if [ -n "${HRTIMER_LOADED}" ]; then | ||
printf "IIO hrtimer module already loaded.\n" | ||
else | ||
if ! modprobe iio_trig_hrtimer ; then | ||
printf "Unable to load load the IIO hrtimer module.\n" | ||
fi | ||
printf "IIO hrtimer module loaded.\n" | ||
fi | ||
|
||
|
||
# ----- Mount the config filesystem ----- | ||
|
||
CONFIG_PATH=$(mount | awk '/^configfs/ { print $3 }') | ||
|
||
if [ -n "$CONFIG_PATH" ]; then | ||
printf "Found configfs at '%s'\n" "${CONFIG_PATH}" | ||
else | ||
CONFIG_PATH=/mnt/config | ||
mkdir -p ${CONFIG_PATH} | ||
if ! mount -t configfs none ${CONFIG_PATH} ; then | ||
printf "Unable to mount configfs\n" | ||
exit 1 | ||
fi | ||
printf "Mounted configfs at %s\n" "${CONFIG_PATH}" | ||
fi | ||
|
||
IIO_CONFIG_PATH=${CONFIG_PATH}/iio | ||
|
||
# ----- Create a dummy device ----- | ||
|
||
if [ ! -d ${IIO_CONFIG_PATH}/devices/dummy ]; then | ||
printf "No configfs path to create IIO devices.\n" | ||
exit 2 | ||
fi | ||
|
||
DEV_CONFIG_PATH=${IIO_CONFIG_PATH}/devices/dummy/${IIO_DEV_NAME} | ||
|
||
if [ -d ${DEV_CONFIG_PATH} ]; then | ||
printf "IIO dummy device already exists.\n" | ||
else | ||
mkdir ${DEV_CONFIG_PATH} | ||
printf "Created IIO dummy device: '%s'\n" "${IIO_DEV_NAME}" | ||
fi | ||
|
||
# ----- Create a timer ----- | ||
|
||
if [ ! -d ${IIO_CONFIG_PATH}/triggers/hrtimer ]; then | ||
printf "No configfs path to create an IIO hrtimer.\n" | ||
else | ||
TIMER_CONFIG_PATH=${IIO_CONFIG_PATH}/triggers/hrtimer/${IIO_TIMER_NAME} | ||
|
||
if [ -d ${TIMER_CONFIG_PATH} ]; then | ||
printf "IIO hrtimer already exists.\n" | ||
else | ||
mkdir ${TIMER_CONFIG_PATH} | ||
printf "Created IIO hrtimer: '%s'\n" "${IIO_TIMER_NAME}" | ||
fi | ||
fi | ||
|
||
# ----- Dump the device info ----- | ||
|
||
printf "\n--- IIO Info ---\n\n" | ||
iio_info | ||
|