1# 2# Copyright (C) 2014 The Android Open Source Project 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15# 16 17LOCAL_PATH := $(call my-dir) 18 19define declare-strace-test-target 20 include $(CLEAR_VARS) 21 LOCAL_SRC_FILES := $(1) 22 LOCAL_MULTILIB := both 23 LOCAL_CFLAGS := -Wno-unused-parameter -Wno-error=return-type 24 LOCAL_MODULE := strace-$(basename $(1))-test 25 LOCAL_MODULE_STEM_32 := strace-$(basename $(1))32-test 26 LOCAL_MODULE_STEM_64 := strace-$(basename $(1))64-test 27 LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES) 28 LOCAL_MODULE_TAGS := tests 29 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 30 include $(BUILD_EXECUTABLE) 31endef 32 33src_files := \ 34 childthread.c \ 35 clone.c \ 36 fork.c \ 37 leaderkill.c \ 38 mmap_offset_decode.c \ 39 mtd.c \ 40 select.c \ 41 sfd.c \ 42 sig.c \ 43 sigkill_rain.c \ 44 sigreturn.c \ 45 skodic.c \ 46 threaded_execve.c \ 47 ubi.c \ 48 vfork.c \ 49 wait_must_be_interruptible.c \ 50 51$(foreach file, $(src_files), $(eval $(call declare-strace-test-target,$(file)))) 52 53# Simple sanity tests meant to be run manually on device. Tests expect that 54# strace will report "exit with 0" at the end of the programs. Some tests 55# document what string should be expected in the output and for them additional 56# checks is made (*-expected output vars)). 57# 58# Failure should be inspected manually. Usually they require a special test 59# setup that can't be easily automated. 60# 61# adb sync is requreired before running "mm run-strace-tests". 62# logs are pulled automatically from the device to the root of the tree 63# (strace-log-*) 64 65childthread-expected-output := 'write(1, "OK\\n",' 66clone-expected-output := 'write(1, "original\\n",' 67fork-expected-output := 'write(1, "parent\\n",' 68leaderkill-expected-output := 'write(1, "OK\\n",' 69mmap_offset_decode-expected-output := '' 70mtd-expected-output := '' 71select-expected-output := '' 72sfd-expected-output := '' 73sig-expected-output := 'write(2, "qwerty\\n",' 74sigkill_rain-expected-output := '' 75sigreturn-expected-output := 'RT_1 RT_3 RT_31 RT_32' 76skodic-expected-output := '' 77threaded_execve-expected-output := '' 78ubi-expected-output := '' 79vfork-expected-output := 'write(1, "parent\\n",' 80wait_must_be_interruptible-expected-output := 'write(1, "Good: wait seems to be correctly"' 81 82run-strace-%-test: TEST_TMP_DIR := /data/local/tmp 83run-strace-%-test: 84 @printf >&2 "\n$*: RUNNING...\n" ; \ 85 adb shell rm -f $(TEST_TMP_DIR)/strace-log-$* ; \ 86 timeout -s 9 10 adb shell strace -v -f -o$(TEST_TMP_DIR)/strace-log-$* strace-$*-test > strace-log-$*-output ; \ 87 adb pull $(TEST_TMP_DIR)/strace-log-$* 2> /dev/null ; \ 88 adb pull $(TEST_TMP_DIR)/strace-log-$*-output 2> /dev/null ; \ 89 if adb shell cat $(TEST_TMP_DIR)/strace-log-$* | grep "exited with 0" > /dev/null ; \ 90 then \ 91 if [ -n $($(shell echo $* | sed 's/[0-9]//g')-expected-output) ] ; then \ 92 if adb shell cat $(TEST_TMP_DIR)/strace-log-$* | grep $($(shell echo $* | sed 's/[0-9]//g')-expected-output) > /dev/null ; \ 93 then printf >&2 "$*: PASSED\n" ; \ 94 else printf >&2 "$*: FAILED\n" ; \ 95 fi ; \ 96 else \ 97 printf >&2 "$*: PASSED\n" ; \ 98 fi ; \ 99 else \ 100 printf >&2 "$*: FAILED\n" ; \ 101 fi 102 103adb-sync: 104 adb sync 105 106run-strace32-test: $(foreach file, $(src_files), run-strace-$(basename $(file))32-test) 107run-strace64-test: $(foreach file, $(src_files), run-strace-$(basename $(file))64-test) 108 109run-strace-tests: adb-sync run-strace32-test run-strace64-test 110