#!/bin/bash

# this file is auto-generated by generate-sensor-autotests, 
# DO NOT EDIT! Edit the generator script instead.

test "$1" = stop && exit 0
sensors=$(test-sensors | grep "type: " | awk "{print $2}")
if echo "$sensors" | grep -q Lux; then
    (
        flock 9
        test-sensors Lux&
    ) 9> /data/test-sensors.lock

    lock_ok=false
    for try in $(seq 1 10); do
        if (flock -n 9) 9> /data/test-sensors.lock; then
            lock_ok=true
            break
        else
            sleep 1
        fi
    done
    if test $try = 10; then
        killall test-sensors
        die "test-sensors did not exit in 10 seconds"
    fi    
else
    echo "Sensor light is not present on this device"
    die "So this case will fail, but you should double check it"
fi
