Native tests use a text file based test list.

Rewrite the nativescanner to parse the output of --gtest_list_tests.

Modify the rules for the xml test list generation to cat the text file
as the source of the test lists. The text file was generated by running
all three gtest tests with the --gtest_list_tests option and saving it
to a file.

Remove the known failures list for bionic tests.

Bug: 10914944

(partial cherry-pick of 2830d721b4173ac7a91e4fc8b9cc0cafaaf86460 from aosp master)

Change-Id: I0a35f191f050e007d2b657b0ad871f38a8f27a9b
diff --git a/build/test_executable.mk b/build/test_executable.mk
index 74b3a95..0d42d02 100644
--- a/build/test_executable.mk
+++ b/build/test_executable.mk
@@ -27,14 +27,14 @@
 
 cts_executable_xml := $(CTS_TESTCASES_OUT)/$(LOCAL_MODULE).xml
 
-$(cts_executable_xml): PRIVATE_PATH := $(cts_src_test_path)
 $(cts_executable_xml): PRIVATE_TEST_PACKAGE := $(LOCAL_CTS_TEST_PACKAGE)
 $(cts_executable_xml): PRIVATE_EXECUTABLE := $(LOCAL_MODULE)
+$(cts_executable_xml): PRIVATE_TEST_LIST := $(LOCAL_PATH)/$(LOCAL_MODULE)_list.txt
 $(cts_executable_xml): $(addprefix $(LOCAL_PATH)/,$(LOCAL_SRC_FILES)) $(CTS_EXPECTATIONS) $(CTS_NATIVE_TEST_SCANNER) $(CTS_XML_GENERATOR)
 	$(hide) echo Generating test description for native package $(PRIVATE_TEST_PACKAGE)
 	$(hide) mkdir -p $(CTS_TESTCASES_OUT)
-	$(hide) $(CTS_NATIVE_TEST_SCANNER) -s $(PRIVATE_PATH) \
-						-t $(PRIVATE_TEST_PACKAGE) | \
+	$(hide) cat $(PRIVATE_TEST_LIST) | \
+			$(CTS_NATIVE_TEST_SCANNER) -t $(PRIVATE_TEST_PACKAGE) | \
 			$(CTS_XML_GENERATOR) -t native \
 						-n $(PRIVATE_EXECUTABLE) \
 						-p $(PRIVATE_TEST_PACKAGE) \
diff --git a/tests/expectations/knownfailures.txt b/tests/expectations/knownfailures.txt
index 9d28c34..9b089df 100644
--- a/tests/expectations/knownfailures.txt
+++ b/tests/expectations/knownfailures.txt
@@ -29,76 +29,5 @@
   name: "android.hardware.cts.SensorIntegrationTests#testSensorsWithSeveralClients",
   name: "android.hardware.cts.SensorIntegrationTests#testSensorsMovingRates",
   bug: 11352697
-},
-{
-  name: "android.bionic.DEATHTEST#bzero_fortified",
-  name: "android.bionic.DEATHTEST#bzero_fortified2",
-  name: "android.bionic.DEATHTEST#memcpy_fortified",
-  name: "android.bionic.DEATHTEST#memmove_fortified",
-  name: "android.bionic.DEATHTEST#snprintf_fortified",
-  name: "android.bionic.DEATHTEST#snprintf_fortified2",
-  name: "android.bionic.DEATHTEST#sprintf2_fortified",
-  name: "android.bionic.DEATHTEST#sprintf2_fortified2",
-  name: "android.bionic.DEATHTEST#sprintf_fortified",
-  name: "android.bionic.DEATHTEST#sprintf_fortified2",
-  name: "android.bionic.DEATHTEST#strcat2_fortified2",
-  name: "android.bionic.DEATHTEST#strcat_fortified",
-  name: "android.bionic.DEATHTEST#strcat_fortified2",
-  name: "android.bionic.DEATHTEST#strchr_fortified",
-  name: "android.bionic.DEATHTEST#strchr_fortified2",
-  name: "android.bionic.DEATHTEST#strcpy2_fortified",
-  name: "android.bionic.DEATHTEST#strcpy2_fortified2",
-  name: "android.bionic.DEATHTEST#strcpy3_fortified",
-  name: "android.bionic.DEATHTEST#strcpy3_fortified2",
-  name: "android.bionic.DEATHTEST#strcpy4_fortified",
-  name: "android.bionic.DEATHTEST#strcpy_fortified",
-  name: "android.bionic.DEATHTEST#strcpy_fortified2",
-  name: "android.bionic.DEATHTEST#strlcat_fortified",
-  name: "android.bionic.DEATHTEST#strlcat_fortified2",
-  name: "android.bionic.DEATHTEST#strlcpy_fortified",
-  name: "android.bionic.DEATHTEST#strlcpy_fortified2",
-  name: "android.bionic.DEATHTEST#strlen_fortified",
-  name: "android.bionic.DEATHTEST#strncat2_fortified",
-  name: "android.bionic.DEATHTEST#strncat2_fortified2",
-  name: "android.bionic.DEATHTEST#strncat3_fortified2",
-  name: "android.bionic.DEATHTEST#strncat_fortified",
-  name: "android.bionic.DEATHTEST#strncat_fortified2",
-  name: "android.bionic.DEATHTEST#strncpy_fortified",
-  name: "android.bionic.DEATHTEST#strncpy_fortified2",
-  name: "android.bionic.DEATHTEST#strrchr_fortified",
-  name: "android.bionic.DEATHTEST#strrchr_fortified2",
-  name: "android.bionic.DEATHTEST#umask_fortified",
-  name: "android.bionic.DEATHTEST#vsnprintf2_fortified",
-  name: "android.bionic.DEATHTEST#vsnprintf2_fortified2",
-  name: "android.bionic.DEATHTEST#vsnprintf_fortified",
-  name: "android.bionic.DEATHTEST#vsnprintf_fortified2",
-  name: "android.bionic.DEATHTEST#vsprintf2_fortified",
-  name: "android.bionic.DEATHTEST#vsprintf2_fortified2",
-  name: "android.bionic.DEATHTEST#vsprintf_fortified",
-  name: "android.bionic.DEATHTEST#vsprintf_fortified2",
-  name: "android.bionic.TEST_NAME#memcpy_chk_max_int_size",
-  name: "android.bionic.TEST_NAME#strcat",
-  name: "android.bionic.TEST_NAME#strcat2",
-  name: "android.bionic.TEST_NAME#strcat_chk_max_int_size",
-  name: "android.bionic.TEST_NAME#strcpy_chk_max_int_size",
-  name: "android.bionic.TEST_NAME#strncat",
-  name: "android.bionic.TEST_NAME#strncat2",
-  name: "android.bionic.TEST_NAME#strncat3",
-  name: "android.bionic.TEST_NAME#strncat4",
-  name: "android.bionic.TEST_NAME#strncat5",
-  name: "android.bionic.TEST_NAME#strncat6",
-  name: "android.bionic.dlfcn#dladdr",
-  name: "android.bionic.dlfcn#dladdr_invalid",
-  name: "android.bionic.dlfcn#dlerror_concurrent",
-  name: "android.bionic.dlfcn#dlopen_bad_flags",
-  name: "android.bionic.dlfcn#dlopen_failure",
-  name: "android.bionic.dlfcn#dlopen_library_with_only_gnu_hash",
-  name: "android.bionic.dlfcn#dlsym_failures",
-  name: "android.bionic.dlfcn#dlsym_in_self",
-  name: "android.bionic.math#isfinite",
-  name: "android.bionic.math#signbit",
-  name: "android.bionic.stack_protector#same_guard_per_thread",
-  name: "android.bionic.stack_unwinding_DeathTest#unwinding_through_signal_frame",
-  bug: 11119006
 }
 ]
diff --git a/tests/tests/bionic/Android.mk b/tests/tests/bionic/Android.mk
index 06b64ea..326fd56 100644
--- a/tests/tests/bionic/Android.mk
+++ b/tests/tests/bionic/Android.mk
@@ -1,26 +1,26 @@
 LOCAL_PATH := $(call my-dir)
 
+test_executable := bionic-unit-tests-cts
+
 include $(CLEAR_VARS)
 
-cts_src_test_path := bionic/tests
+LOCAL_MODULE := $(test_executable)
 LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE := bionic-unit-tests-cts
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)/nativetest
 
 LOCAL_ADDITION_DEPENDENCIES := \
-	$(LOCAL_PATH)/Android.mk \
+    $(LOCAL_PATH)/Android.mk \
 
 LOCAL_SHARED_LIBRARIES += \
-	libstlport \
-	libdl \
+    libstlport \
+    libdl \
 
 LOCAL_WHOLE_STATIC_LIBRARIES += \
-	libBionicTests \
+    libBionicTests \
 
 LOCAL_STATIC_LIBRARIES += \
-	libgtest \
-	libgtest_main \
+    libgtest \
+    libgtest_main \
 
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)/nativetest
 LOCAL_CTS_TEST_PACKAGE := android.bionic
-
 include $(BUILD_CTS_EXECUTABLE)
diff --git a/tests/tests/bionic/bionic-unit-tests-cts_list.txt b/tests/tests/bionic/bionic-unit-tests-cts_list.txt
new file mode 100644
index 0000000..55daff5
--- /dev/null
+++ b/tests/tests/bionic/bionic-unit-tests-cts_list.txt
@@ -0,0 +1,576 @@
+Fortify1_Gcc_DeathTest.
+  strcpy_fortified
+  strcpy2_fortified
+  strcpy3_fortified
+  strcpy4_fortified
+  strlen_fortified
+  strchr_fortified
+  strrchr_fortified
+  strlcpy_fortified
+  strlcat_fortified
+  sprintf_fortified
+  sprintf2_fortified
+  vsprintf_fortified
+  vsprintf2_fortified
+  vsnprintf_fortified
+  vsnprintf2_fortified
+  strncat_fortified
+  strncat2_fortified
+  strcat_fortified
+  memmove_fortified
+  memcpy_fortified
+  strncpy_fortified
+  snprintf_fortified
+  bzero_fortified
+  umask_fortified
+Fortify2_Gcc_DeathTest.
+  strncpy_fortified2
+  sprintf_fortified2
+  sprintf2_fortified2
+  vsprintf_fortified2
+  vsprintf2_fortified2
+  vsnprintf_fortified2
+  vsnprintf2_fortified2
+  strcpy_fortified2
+  strcpy2_fortified2
+  strcpy3_fortified2
+  strchr_fortified2
+  strrchr_fortified2
+  strlcpy_fortified2
+  strlcat_fortified2
+  strncat_fortified2
+  strncat2_fortified2
+  strncat3_fortified2
+  strcat_fortified2
+  strcat2_fortified2
+  snprintf_fortified2
+  bzero_fortified2
+  strcpy_fortified
+  strcpy2_fortified
+  strcpy3_fortified
+  strcpy4_fortified
+  strlen_fortified
+  strchr_fortified
+  strrchr_fortified
+  strlcpy_fortified
+  strlcat_fortified
+  sprintf_fortified
+  sprintf2_fortified
+  vsprintf_fortified
+  vsprintf2_fortified
+  vsnprintf_fortified
+  vsnprintf2_fortified
+  strncat_fortified
+  strncat2_fortified
+  strcat_fortified
+  memmove_fortified
+  memcpy_fortified
+  strncpy_fortified
+  snprintf_fortified
+  bzero_fortified
+  umask_fortified
+Fortify1_Clang_DeathTest.
+  strcpy_fortified
+  strcpy2_fortified
+  strcpy3_fortified
+  strcpy4_fortified
+  strlen_fortified
+  strchr_fortified
+  strrchr_fortified
+  strlcpy_fortified
+  strlcat_fortified
+  sprintf_fortified
+  sprintf2_fortified
+  vsprintf_fortified
+  vsprintf2_fortified
+  vsnprintf_fortified
+  vsnprintf2_fortified
+  strncat_fortified
+  strncat2_fortified
+  strcat_fortified
+  memmove_fortified
+  memcpy_fortified
+  strncpy_fortified
+  snprintf_fortified
+  bzero_fortified
+  umask_fortified
+Fortify2_Clang_DeathTest.
+  strncat3_fortified2
+  strcat2_fortified2
+  snprintf_fortified2
+  bzero_fortified2
+  strcpy_fortified
+  strcpy2_fortified
+  strcpy3_fortified
+  strcpy4_fortified
+  strlen_fortified
+  strchr_fortified
+  strrchr_fortified
+  strlcpy_fortified
+  strlcat_fortified
+  sprintf_fortified
+  sprintf2_fortified
+  vsprintf_fortified
+  vsprintf2_fortified
+  vsnprintf_fortified
+  vsnprintf2_fortified
+  strncat_fortified
+  strncat2_fortified
+  strcat_fortified
+  memmove_fortified
+  memcpy_fortified
+  strncpy_fortified
+  snprintf_fortified
+  bzero_fortified
+  umask_fortified
+pthread_DeathTest.
+  pthread_bug_37410
+stack_protector_DeathTest.
+  modify_stack_protector
+properties_DeathTest.
+  read_only
+Fortify1_Gcc.
+  strncat
+  strncat2
+  strncat3
+  strncat4
+  strncat5
+  strncat6
+  strcat
+  strcat2
+  strcat_chk_max_int_size
+  strcpy_chk_max_int_size
+  memcpy_chk_max_int_size
+Fortify2_Gcc.
+  strncat
+  strncat2
+  strncat3
+  strncat4
+  strncat5
+  strncat6
+  strcat
+  strcat2
+  strcat_chk_max_int_size
+  strcpy_chk_max_int_size
+  memcpy_chk_max_int_size
+Fortify1_Clang.
+  strncat
+  strncat2
+  strncat3
+  strncat4
+  strncat5
+  strncat6
+  strcat
+  strcat2
+  strcat_chk_max_int_size
+  strcpy_chk_max_int_size
+  memcpy_chk_max_int_size
+Fortify2_Clang.
+  strncat
+  strncat2
+  strncat3
+  strncat4
+  strncat5
+  strncat6
+  strcat
+  strcat2
+  strcat_chk_max_int_size
+  strcpy_chk_max_int_size
+  memcpy_chk_max_int_size
+dirent.
+  scandir
+  fdopendir_invalid
+  fdopendir
+  opendir_invalid
+  opendir
+  closedir_invalid
+  closedir
+  readdir
+  readdir_r
+  rewinddir
+eventfd.
+  smoke
+fenv.
+  fesetround_fegetround_FE_TONEAREST
+  fesetround_fegetround_FE_TOWARDZERO
+  fesetround_fegetround_FE_UPWARD
+  fesetround_fegetround_FE_DOWNWARD
+  feclearexcept_fetestexcept
+  FE_DFL_ENV_macro
+getauxval.
+  expected_values
+  unexpected_values
+getcwd.
+  auto_full
+  auto_reasonable
+  auto_too_small
+  auto_too_large
+  manual_too_small
+  manual_zero
+  manual_path_max
+inttypes.
+  misc
+libc_logging.
+  smoke
+  d_INT_MAX
+  d_INT_MIN
+  ld_LONG_MAX
+  ld_LONG_MIN
+  lld_LLONG_MAX
+  lld_LLONG_MIN
+libgen.
+  basename
+  dirname
+  basename_r
+  dirname_r
+malloc.
+  malloc_std
+  calloc_std
+  memalign_multiple
+  memalign_realloc
+  malloc_realloc_larger
+  malloc_realloc_smaller
+  malloc_multiple_realloc
+  calloc_realloc_larger
+  calloc_realloc_smaller
+  calloc_multiple_realloc
+math.
+  fpclassify
+  isinf
+  isnan
+  isnormal
+  __fpclassifyd
+  __fpclassifyf
+  __fpclassifyl
+  finitef
+  __isfinite
+  __isfinitef
+  __isfinitel
+  finite
+  __isinff
+  __isinfl
+  __isnanf
+  __isnanl
+  isnanf
+  __isnormal
+  __isnormalf
+  __isnormall
+  __signbit
+  __signbitf
+  __signbitl
+  acos
+  acosf
+  acosl
+  asin
+  asinf
+  asinl
+  atan
+  atanf
+  atanl
+  atan2
+  atan2f
+  atan2l
+  cos
+  cosf
+  cosl
+  sin
+  sinf
+  sinl
+  tan
+  tanf
+  tanl
+  acosh
+  acoshf
+  acoshl
+  asinh
+  asinhf
+  asinhl
+  atanh
+  atanhf
+  atanhl
+  cosh
+  coshf
+  coshl
+  sinh
+  sinhf
+  sinhl
+  tanh
+  tanhf
+  tanhl
+  log
+  logf
+  logl
+  log2
+  log2f
+  log2l
+  log10
+  log10f
+  log10l
+  cbrt
+  cbrtf
+  cbrtl
+  sqrt
+  sqrtf
+  sqrtl
+  exp
+  expf
+  expl
+  exp2
+  exp2f
+  exp2l
+  expm1
+  expm1f
+  expm1l
+  pow
+  powf
+  powl
+  ceil
+  ceilf
+  ceill
+  floor
+  floorf
+  floorl
+  fabs
+  fabsf
+  fabsl
+  ldexp
+  ldexpf
+  ldexpl
+  fmod
+  fmodf
+  fmodl
+  remainder
+  remainderf
+  remainderl
+  drem
+  dremf
+  fmax
+  fmaxf
+  fmaxl
+  fmin
+  fminf
+  fminl
+  fma
+  fmaf
+  fmal
+  hypot
+  hypotf
+  hypotl
+  erf
+  erff
+  erfl
+  erfc
+  erfcf
+  erfcl
+  lrint
+  rint
+  nearbyint
+  lround
+  llround
+  ilogb
+  ilogbf
+  ilogbl
+  logb
+  logbf
+  logbl
+  log1p
+  log1pf
+  log1pl
+  fdim
+  fdimf
+  fdiml
+  round
+  roundf
+  roundl
+  trunc
+  truncf
+  truncl
+  nextafter
+  nextafterf
+  nextafterl
+  copysign
+  copysignf
+  copysignl
+  significand
+  significandf
+  significandl
+  scalb
+  scalbf
+  scalbln
+  scalblnf
+  scalblnl
+  scalbn
+  scalbnf
+  scalbnl
+  gamma
+  gammaf
+  gamma_r
+  gammaf_r
+  lgamma
+  lgammaf
+  lgammal
+  lgamma_r
+  lgammaf_r
+  tgamma
+  tgammaf
+  tgammal
+  j0
+  j0f
+  j1
+  j1f
+  jn
+  jnf
+  y0
+  y0f
+  y1
+  y1f
+  yn
+  ynf
+  frexp
+  frexpf
+  frexpl
+  modf
+  modff
+  modfl
+  remquo
+  remquof
+  remquol
+  frexpf_public_bug_6697
+netdb.
+  getaddrinfo_NULL_hints
+  getnameinfo_salen
+pthread.
+  pthread_key_create
+  pthread_key_create_lots
+  pthread_create
+  pthread_create_EAGAIN
+  pthread_no_join_after_detach
+  pthread_no_op_detach_after_join
+  pthread_join_self
+  pthread_sigmask
+  __pthread_clone
+  pthread_setname_np__too_long
+  pthread_setname_np__self
+  pthread_setname_np__other
+  pthread_setname_np__no_such_thread
+  pthread_kill__0
+  pthread_kill__invalid_signal
+  pthread_kill__in_signal_handler
+  pthread_detach__no_such_thread
+  pthread_getcpuclockid__clock_gettime
+  pthread_getcpuclockid__no_such_thread
+  pthread_getschedparam__no_such_thread
+  pthread_setschedparam__no_such_thread
+  pthread_join__no_such_thread
+  pthread_kill__no_such_thread
+  pthread_join__multijoin
+  pthread_attr_setguardsize
+  pthread_attr_setstacksize
+regex.
+  smoke
+signal.
+  sigismember_invalid
+  sigaddset_invalid
+  sigdelset_invalid
+  sigemptyset_invalid
+  sigfillset_invalid
+  raise_invalid
+  raise_in_signal_handler
+  sigwait
+stack_protector.
+  global_guard
+statvfs.
+  statvfs
+  fstatvfs
+stdio.
+  tmpfile_fileno_fprintf_rewind_fgets
+  getdelim
+  getdelim_invalid
+  getline
+  getline_invalid
+  printf_ssize_t
+  popen
+  getc
+  putc
+stdlib.
+  drand48
+  lrand48_random_rand
+  mrand48
+  posix_memalign
+  realpath__NULL_filename
+  realpath__empty_filename
+  realpath__ENOENT
+  realpath
+  qsort
+string.
+  strerror
+  strerror_concurrent
+  strerror_r
+  strsignal
+  strsignal_concurrent
+  strcat
+  strcpy2
+  strcpy3
+  strcpy4
+  strcat2
+  strcat3
+  strncat2
+  strncat3
+  strncat4
+  strncat5
+  strchr_with_0
+  strchr
+  strcmp
+  strcpy
+  strlcat
+  strlcpy
+  strncat
+  strncmp
+  strncpy
+  strrchr
+  memchr
+  memrchr
+  memcmp
+  __memcmp16
+  wmemcmp
+  memcpy
+  memset
+  memmove
+  bcopy
+  bzero
+strings.
+  ffs
+getpwnam.
+  system_id_root
+  system_id_system
+  app_id_radio
+  app_id_nobody
+  app_id_all_a0
+  app_id_u1_a40000
+  app_id_u0_a0
+  app_id_u0_a1234
+  app_id_u0_a9999
+  app_id_u1_root
+  app_id_u1_radio
+  app_id_u1_a0
+  app_id_u1_i0
+sys_stat.
+  futimens
+  futimens_EBADF
+properties.
+  add
+  update
+  fill
+  foreach
+  find_nth
+  fill_hierarchical
+  errors
+  serial
+  wait
+time.
+  mktime_tz
+  gmtime
+  mktime_10310929
+unistd.
+  sysconf_SC_MONOTONIC_CLOCK
+  sbrk
diff --git a/tests/tests/nativemedia/sl/Android.mk b/tests/tests/nativemedia/sl/Android.mk
index 90d8863..49ccb10 100644
--- a/tests/tests/nativemedia/sl/Android.mk
+++ b/tests/tests/nativemedia/sl/Android.mk
@@ -1,13 +1,16 @@
 # Build the unit tests.
 
 LOCAL_PATH:= $(call my-dir)
+
+test_executable := NativeMediaTest_SL
+
 include $(CLEAR_VARS)
 
-cts_src_test_path := $(LOCAL_PATH)
-
+LOCAL_MODULE := $(test_executable)
 LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)/nativetest
 
-LOCAL_C_INCLUDES:= \
+LOCAL_C_INCLUDES := \
     bionic \
     bionic/libstdc++/include \
     external/gtest/include \
@@ -15,22 +18,18 @@
     external/stlport/stlport \
     $(call include-path-for, wilhelm-ut)
 
-LOCAL_SRC_FILES:= \
+LOCAL_SRC_FILES := \
     src/SLObjectCreationTest.cpp
 
 LOCAL_SHARED_LIBRARIES := \
-  libutils \
-  liblog \
-  libOpenSLES \
-  libstlport
+    libutils \
+    liblog \
+    libOpenSLES \
+    libstlport
 
 LOCAL_STATIC_LIBRARIES := \
     libOpenSLESUT \
     libgtest
 
-LOCAL_MODULE:= NativeMediaTest_SL
-
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)/nativetest
-
 LOCAL_CTS_TEST_PACKAGE := android.nativemedia.sl
 include $(BUILD_CTS_EXECUTABLE)
diff --git a/tests/tests/nativemedia/sl/NativeMediaTest_SL_list.txt b/tests/tests/nativemedia/sl/NativeMediaTest_SL_list.txt
new file mode 100644
index 0000000..c5d17a3
--- /dev/null
+++ b/tests/tests/nativemedia/sl/NativeMediaTest_SL_list.txt
@@ -0,0 +1,11 @@
+SLObjectCreationTest.
+  testEngineCreation
+  testOutputMixCreation
+  testAudioPlayerFromUriCreation
+  testAudioPlayerFromFdCreation
+  testAudioPlayerFromPcmBqCreation
+  testAudioPlayerFromTsAbqCreation
+  testAudioPlayerFromUriToPcmBqCreation
+  testAudioPlayerFromFdToPcmBqCreation
+  testAudioPlayerFromAdtsAbqToPcmBqCreation
+  testAudioRecorderCreation
diff --git a/tests/tests/nativemedia/sl/src/SLObjectCreationTest.cpp b/tests/tests/nativemedia/sl/src/SLObjectCreationTest.cpp
index 804263e..d0b3be0 100644
--- a/tests/tests/nativemedia/sl/src/SLObjectCreationTest.cpp
+++ b/tests/tests/nativemedia/sl/src/SLObjectCreationTest.cpp
@@ -35,12 +35,16 @@
 #define LOG_NDEBUG 0
 #define LOG_TAG "SLObjectCreationTest"
 
+#include <gtest/gtest.h>
 #include <utils/Log.h>
+
+#if !defined(BUILD_ONLY)
 #include "SLES/OpenSLES.h"
 #include "SLES/OpenSLES_Android.h"
 #include "OpenSLESUT.h"
-#include <gtest/gtest.h>
+#endif
 
+#if !defined(BUILD_ONLY)
 //-----------------------------------------------------------------
 /* Checks for error and displays the error code if any */
 bool IsOk(SLresult res) {
@@ -305,6 +309,20 @@
         (*audioRecorderObj)->Destroy(audioRecorderObj);
     }
 };
+#else
+class SLObjectCreationTest : public ::testing::Test {
+protected:
+    void OutputMixCreation() { }
+    void AudioPlayerFromUriCreation() { }
+    void AudioPlayerFromFdCreation() { }
+    void AudioPlayerFromPcmBqCreation() { }
+    void AudioPlayerFromTsAbqCreation() { }
+    void AudioPlayerFromUriToPcmBqCreation() { }
+    void AudioPlayerFromFdToPcmBqCreation() { }
+    void AudioPlayerFromAdtsAbqToPcmBqCreation() { }
+    void AudioRecorderCreation(bool) { }
+};
+#endif
 
 //-------------------------------------------------------------------------------------------------
 TEST_F(SLObjectCreationTest, testEngineCreation) {
diff --git a/tests/tests/nativemedia/xa/Android.mk b/tests/tests/nativemedia/xa/Android.mk
index 9ff2110..f2c0ca0 100644
--- a/tests/tests/nativemedia/xa/Android.mk
+++ b/tests/tests/nativemedia/xa/Android.mk
@@ -1,13 +1,16 @@
 # Build the unit tests.
 
 LOCAL_PATH:= $(call my-dir)
+
+test_executable := NativeMediaTest_XA
+
 include $(CLEAR_VARS)
 
-cts_src_test_path := $(LOCAL_PATH)
-
+LOCAL_MODULE:= $(test_executable)
 LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)/nativetest
 
-LOCAL_C_INCLUDES:= \
+LOCAL_C_INCLUDES := \
     bionic \
     bionic/libstdc++/include \
     external/gtest/include \
@@ -15,7 +18,7 @@
     external/stlport/stlport \
     $(call include-path-for, wilhelm-ut)
 
-LOCAL_SRC_FILES:= \
+LOCAL_SRC_FILES := \
     src/XAObjectCreationTest.cpp
 
 LOCAL_SHARED_LIBRARIES := \
@@ -27,9 +30,5 @@
 LOCAL_STATIC_LIBRARIES := \
     libgtest
 
-LOCAL_MODULE:= NativeMediaTest_XA
-
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)/nativetest
-
 LOCAL_CTS_TEST_PACKAGE := android.nativemedia.xa
 include $(BUILD_CTS_EXECUTABLE)
diff --git a/tests/tests/nativemedia/xa/NativeMediaTest_XA_list.txt b/tests/tests/nativemedia/xa/NativeMediaTest_XA_list.txt
new file mode 100644
index 0000000..af8bfad
--- /dev/null
+++ b/tests/tests/nativemedia/xa/NativeMediaTest_XA_list.txt
@@ -0,0 +1,3 @@
+XAObjectCreationTest.
+  testEngineCreation
+  testOutputMixCreation
diff --git a/tests/tests/nativemedia/xa/src/XAObjectCreationTest.cpp b/tests/tests/nativemedia/xa/src/XAObjectCreationTest.cpp
index 3ff84c2..d905451 100644
--- a/tests/tests/nativemedia/xa/src/XAObjectCreationTest.cpp
+++ b/tests/tests/nativemedia/xa/src/XAObjectCreationTest.cpp
@@ -24,12 +24,15 @@
 #define LOG_NDEBUG 0
 #define LOG_TAG "XAObjectCreationTest"
 
+#include <gtest/gtest.h>
 #include <utils/Log.h>
+
+#if !defined(BUILD_ONLY)
 #include "OMXAL/OpenMAXAL.h"
 #include "OMXAL/OpenMAXAL_Android.h"
-//#include <android/native_window_jni.h>
-#include <gtest/gtest.h>
+#endif
 
+#if !defined(BUILD_ONLY)
 //-----------------------------------------------------------------
 /* Checks for error and displays the error code if any */
 bool IsOk(XAresult res) {
@@ -115,6 +118,12 @@
     }
 
 };
+#else
+class XAObjectCreationTest : public ::testing::Test {
+protected:
+    void OutputMixCreation() { }
+};
+#endif
 
 //-------------------------------------------------------------------------------------------------
 TEST_F(XAObjectCreationTest, testEngineCreation) {
diff --git a/tools/cts-native-scanner/src/com/android/cts/nativescanner/CtsNativeScanner.java b/tools/cts-native-scanner/src/com/android/cts/nativescanner/CtsNativeScanner.java
index a7599b0..2414138 100644
--- a/tools/cts-native-scanner/src/com/android/cts/nativescanner/CtsNativeScanner.java
+++ b/tools/cts-native-scanner/src/com/android/cts/nativescanner/CtsNativeScanner.java
@@ -15,7 +15,8 @@
  */
 package com.android.cts.nativescanner;
 
-import java.io.File;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
 import java.util.Arrays;
 import java.util.List;
 
@@ -27,18 +28,18 @@
 
     private static void usage(String[] args) {
         System.err.println("Arguments: " + Arrays.asList(args));
-        System.err.println("Usage: cts-native-scanner -s SOURCE_DIR -t TEST_SUITE");
+        System.err.println("Usage: cts-native-scanner -t TEST_SUITE");
+        System.err.println("  This code reads from stdin the list of tests.");
+        System.err.println("  The format expected:");
+        System.err.println("    TEST_CASE_NAME.");
+        System.err.println("      TEST_NAME");
         System.exit(1);
     }
 
     public static void main(String[] args) throws Exception {
-        File sourceDir = null;
         String testSuite = null;
-
         for (int i = 0; i < args.length; i++) {
-            if ("-s".equals(args[i])) {
-                sourceDir = new File(getArg(args, ++i, "Missing value for source directory"));
-            } else if ("-t".equals(args[i])) {
+            if ("-t".equals(args[i])) {
                 testSuite = getArg(args, ++i, "Missing value for test suite");
             } else {
                 System.err.println("Unsupported flag: " + args[i]);
@@ -46,19 +47,14 @@
             }
         }
 
-        if (sourceDir == null) {
-            System.out.println("Source directory is required");
-            usage(args);
-        }
-
         if (testSuite == null) {
             System.out.println("Test suite is required");
             usage(args);
         }
 
-        TestScanner scanner = new TestScanner(sourceDir, testSuite);
-        List<String> testNames = scanner.getTestNames();
-        for (String name : testNames) {
+        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
+        TestScanner scanner = new TestScanner(reader, testSuite);
+        for (String name : scanner.getTestNames()) {
             System.out.println(name);
         }
     }
diff --git a/tools/cts-native-scanner/src/com/android/cts/nativescanner/TestScanner.java b/tools/cts-native-scanner/src/com/android/cts/nativescanner/TestScanner.java
index 370b509..6fcb353 100644
--- a/tools/cts-native-scanner/src/com/android/cts/nativescanner/TestScanner.java
+++ b/tools/cts-native-scanner/src/com/android/cts/nativescanner/TestScanner.java
@@ -16,100 +16,60 @@
 
 package com.android.cts.nativescanner;
 
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FilenameFilter;
+import java.io.BufferedReader;
 import java.io.IOException;
+import java.io.InputStreamReader;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Scanner;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
 
 /**
- * Scanner of C++ gTest source files.
+ * Read from the BufferedReader a list of test case names and test cases.
  *
- * It looks for test declarations and outputs a file following this format:
- * suite:TestSuite
- * case:TestCase1
- * test:Test1
- * test:Test2
- * suite:TestSuite
- * case:TestCase2
- * test:Test1
- * test:Test2
+ * The expected format of the incoming test list:
+ *   TEST_CASE_NAME.
+ *     TEST_NAME1
+ *     TEST_NAME2
  *
+ * The output:
+ *   suite:TestSuite
+ *   case:TEST_CASE_NAME
+ *   test:TEST_NAME1
+ *   test:TEST_NAME2
  */
 class TestScanner {
 
-    /** Directory to recursively scan for gTest test declarations. */
-    private final File mSourceDir;
-
     private final String mTestSuite;
 
-    TestScanner(File sourceDir, String testSuite) {
-        mSourceDir = sourceDir;
+    private final BufferedReader mReader;
+
+    TestScanner(BufferedReader reader, String testSuite) {
         mTestSuite = testSuite;
+        mReader = reader;
     }
 
     public List<String> getTestNames() throws IOException {
         List<String> testNames = new ArrayList<String>();
-        scanDir(mSourceDir, testNames);
-        return testNames;
-    }
 
-    private void scanDir(File dir, List<String> testNames) throws FileNotFoundException {
-        // Find both C++ files to find tests and directories to look for more tests!
-        File[] files = dir.listFiles(new FilenameFilter() {
-            @Override
-            public boolean accept(File dir, String filename) {
-                return filename.endsWith(".cpp") || filename.endsWith(".cc")
-                        || new File(dir, filename).isDirectory();
-            }
-        });
-
-        for (int i = 0; i < files.length; i++) {
-            File file = files[i];
-            if (file.isDirectory()) {
-                scanDir(file, testNames);
+        String testCaseName = null;
+        String line;
+        while ((line = mReader.readLine()) != null) {
+          if (line.length() > 0) {
+            if (line.charAt(0) == ' ') {
+              if (testCaseName != null) {
+                testNames.add("test:" + line.trim());
+              } else {
+                throw new IOException("TEST_CASE_NAME not defined before first test.");
+              }
             } else {
-                scanFile(new Scanner(file), testNames);
+              testCaseName = line.trim();
+              if (testCaseName.endsWith(".")) {
+                testCaseName = testCaseName.substring(0, testCaseName.length()-1);
+              }
+              testNames.add("suite:" + mTestSuite);
+              testNames.add("case:" + testCaseName);
             }
+          }
         }
-    }
-
-    // We want to find lines like TEST_F(SLObjectCreationTest, testAudioPlayerFromFdCreation)
-    // or TEST(stdio, printf) { ...
-    // and extract the "SLObjectCreationTest" as group #1,
-    // "testAudioPlayerFromFdCreation" as group #2
-    // TODO: It would be better to concatenate the two parts.
-    private static final Pattern METHOD_REGEX =
-            Pattern.compile("\\s*TEST(?:_F)?\\((\\w+),\\s*(\\w+)\\).*");
-
-    public void scanFile(Scanner scanner, List<String> testNames) {
-        try {
-            String lastCase = "";
-            while (scanner.hasNextLine()) {
-                String line = scanner.nextLine();
-
-                Matcher matcher = METHOD_REGEX.matcher(line);
-
-                if (!matcher.matches()) {
-                    continue;
-                }
-
-                if (!lastCase.equals(matcher.group(1))) {
-                    testNames.add("suite:" + mTestSuite);
-                    testNames.add("case:" + matcher.group(1));
-                    lastCase = matcher.group(1);
-                }
-
-                testNames.add("test:" + matcher.group(2));
-            }
-        } finally {
-            if (scanner != null) {
-                scanner.close();
-            }
-        }
+        return testNames;
     }
 }
diff --git a/tools/cts-native-scanner/tests/src/com/android/cts/nativescanner/TestScannerTest.java b/tools/cts-native-scanner/tests/src/com/android/cts/nativescanner/TestScannerTest.java
index 18732fd..b00c7dc 100644
--- a/tools/cts-native-scanner/tests/src/com/android/cts/nativescanner/TestScannerTest.java
+++ b/tools/cts-native-scanner/tests/src/com/android/cts/nativescanner/TestScannerTest.java
@@ -19,12 +19,10 @@
 
 import junit.framework.TestCase;
 
-import java.io.File;
+import java.io.BufferedReader;
+import java.io.IOException;
 import java.io.StringReader;
-import java.lang.StringBuilder;
-import java.util.Scanner;
 import java.util.List;
-import java.util.ArrayList;
 import java.util.Iterator;
 
 /**
@@ -32,31 +30,49 @@
  */
 public class TestScannerTest extends TestCase {
 
-    public void testScanFile() {
-        TestScanner testScanner = new TestScanner(new File("unused"), "TestSuite");
+    public void testSingleTestNamesCase() throws Exception {
+        StringReader singleTestString = new StringReader("FakeTestCase.\n  FakeTestName\n");
+        BufferedReader reader = new BufferedReader(singleTestString);
 
-        String newLine = System.getProperty("line.separator");
-        StringBuilder sb = new StringBuilder();
-        sb.append("foobar" + newLine);  // ignored
-        sb.append("TEST_F(TestCase1, TestName1)" + newLine);  // valid
-        sb.append("TEST_F(TestCase1, TestName2)" + newLine);  // valid
-        sb.append("TEST_F(TestCase2, TestName1) foo" + newLine);  // valid
-        sb.append("TEST_F(TestCase2, TestName1 foo)" + newLine);  // ignored
-        sb.append("foo TEST_F(TestCase2, TestName1)" + newLine);  // ignored
+        TestScanner testScanner = new TestScanner(reader, "TestSuite");
 
-        List<String> names = new ArrayList<String>();
-        Scanner scanner = new Scanner(new StringReader(sb.toString()));
-        testScanner.scanFile(scanner, names);
+        List<String> names = testScanner.getTestNames();
         Iterator it = names.iterator();
-
         assertEquals("suite:TestSuite", it.next());
-        assertEquals("case:TestCase1", it.next());
-        assertEquals("test:TestName1", it.next());
-        assertEquals("test:TestName2", it.next());
-        assertEquals("suite:TestSuite", it.next());
-        assertEquals("case:TestCase2", it.next());
-        assertEquals("test:TestName1", it.next());
+        assertEquals("case:FakeTestCase", it.next());
+        assertEquals("test:FakeTestName", it.next());
         assertFalse(it.hasNext());
-        scanner.close();
+    }
+
+    public void testMultipleTestNamesCase() throws Exception {
+        StringReader singleTestString = new StringReader(
+          "Case1.\n  Test1\n  Test2\nCase2.\n  Test3\n Test4\n");
+        BufferedReader reader = new BufferedReader(singleTestString);
+
+        TestScanner testScanner = new TestScanner(reader, "TestSuite");
+
+        List<String> names = testScanner.getTestNames();
+        Iterator it = names.iterator();
+        assertEquals("suite:TestSuite", it.next());
+        assertEquals("case:Case1", it.next());
+        assertEquals("test:Test1", it.next());
+        assertEquals("test:Test2", it.next());
+        assertEquals("case:Case2", it.next());
+        assertEquals("test:Test3", it.next());
+        assertEquals("test:Test4", it.next());
+        assertFalse(it.hasNext());
+    }
+
+    public void testMissingTestCaseNameCase() {
+        StringReader singleTestString = new StringReader("  Test1\n");
+        BufferedReader reader = new BufferedReader(singleTestString);
+
+        TestScanner testScanner = new TestScanner(reader, "TestSuite");
+
+        try {
+          List<String> names = testScanner.getTestNames();
+          fail();
+        } catch (IOException expected) {
+        }
     }
 }