platform_system_core/init/test_service
Chih-Hung Hsieh 122352d983 Use -Werror in system/core
* Move -Wall -Werror from cppflags to cflags.
* Fix/suppress warning on unused variables.

Bug: 66996870
Test: build with WITH_TIDY=1
Change-Id: I1e05e96a1d0bcb2ccef1ce456504b3af57167cc5
2017-11-01 11:32:55 -07:00
..
Android.bp Use -Werror in system/core 2017-11-01 11:32:55 -07:00
README.md Add a sample service for testing init. 2017-02-09 18:23:09 -05:00
test_service.cpp Use -Werror in system/core 2017-11-01 11:32:55 -07:00
test_service.rc Add a sample service for testing init. 2017-02-09 18:23:09 -05:00

Sample service for testing

This is a sample service that can be used for testing init.

Design

The service includes a .rc file that allows starting it from init.

service test_service /system/bin/test_service CapAmb 0000000000003000
    class main
    user system
    group system
    capabilities NET_ADMIN NET_RAW
    disabled
    oneshot

The service accepts any even number of arguments on the command line (i.e. any number of pairs of arguments.) It will attempt to find the first element of each pair of arguments in /proc/self/status, and attempt to exactly match the second element of the pair to the relevant line of proc/self/status.

Example

In the above case, the service will look for lines containing CapAmb:

cat /proc/self/status
...
CapAmb:	0000000000003000

And then attempt to exactly match the token after :, 0000000000003000, with the command-line argument. If they match, the service exits successfully. If not, the service will exit with an error.

Usage

mmma -j <jobs> system/core/init/testservice
adb root
adb remount
adb sync
adb reboot
adb root
adb shell start test_service
adb logcat -b all -d | grep test_service

Look for an exit status of 0.