versioner: kill some obsolete versions.

Make the selection of a non-default API level non-fatal, so that we
won't have to continually fix all of the tests every time we remove an
API version.

Test: versioner
Test: python run_tests.py
Change-Id: I96429584e352f7e012c5129da3c02dc1b4b30061
diff --git a/tools/versioner/src/Arch.h b/tools/versioner/src/Arch.h
index 0c6f514..ab05d5c 100644
--- a/tools/versioner/src/Arch.h
+++ b/tools/versioner/src/Arch.h
@@ -136,7 +136,7 @@
   { Arch::x86_64, "x86_64-linux-android" },
 };
 
-static const std::set<int> supported_levels = { 9, 12, 13, 14, 15, 16, 17, 18, 19, 21, 23, 24 };
+static const std::set<int> default_levels = { 14, 15, 16, 17, 18, 19, 21, 23, 24, 25, 26, 27 };
 
 static const ArchMap<int> arch_min_api = {
   { Arch::arm, 9 },
diff --git a/tools/versioner/src/SymbolDatabase.cpp b/tools/versioner/src/SymbolDatabase.cpp
index bd4b99d..8521f4d 100644
--- a/tools/versioner/src/SymbolDatabase.cpp
+++ b/tools/versioner/src/SymbolDatabase.cpp
@@ -70,11 +70,6 @@
   int api_level = type.api_level;
   std::ifstream stream;
   while (api_level >= arch_min_api[type.arch]) {
-    if (supported_levels.count(api_level) == 0) {
-      --api_level;
-      continue;
-    }
-
     std::string path = std::string(platform_dir) + "/android-" + std::to_string(api_level) +
                        "/arch-" + to_string(type.arch) + "/symbols/" + filename;
 
diff --git a/tools/versioner/src/versioner.cpp b/tools/versioner/src/versioner.cpp
index 8db75d7..83b4027 100644
--- a/tools/versioner/src/versioner.cpp
+++ b/tools/versioner/src/versioner.cpp
@@ -451,7 +451,7 @@
     fprintf(stderr, "\n");
     fprintf(stderr, "Target specification (defaults to all):\n");
     fprintf(stderr, "  -a API_LEVEL\tbuild with specified API level (can be repeated)\n");
-    fprintf(stderr, "    \t\tvalid levels are %s\n", Join(supported_levels).c_str());
+    fprintf(stderr, "    \t\tdefaults to %s\n", Join(default_levels).c_str());
     fprintf(stderr, "  -r ARCH\tbuild with specified architecture (can be repeated)\n");
     fprintf(stderr, "    \t\tvalid architectures are %s\n", Join(supported_archs).c_str());
     fprintf(stderr, "\n");
@@ -501,10 +501,6 @@
           usage();
         }
 
-        if (supported_levels.count(api_level) == 0) {
-          errx(1, "unsupported API level %d", api_level);
-        }
-
         selected_levels.insert(api_level);
         break;
       }
@@ -629,7 +625,7 @@
   }
 
   if (selected_levels.empty()) {
-    selected_levels = supported_levels;
+    selected_levels = default_levels;
   }
 
   if (selected_architectures.empty()) {
diff --git a/tools/versioner/tests/preprocessor/run.sh b/tools/versioner/tests/preprocessor/run.sh
index 60e7024..50d9b5c 100644
--- a/tools/versioner/tests/preprocessor/run.sh
+++ b/tools/versioner/tests/preprocessor/run.sh
@@ -4,7 +4,7 @@
   SRC=$1
   DST=$2
   rm -rf $2
-  versioner $1 -i -o $2
+  versioner -a 9 -a 12 -a 13 -a 14 -a 15 $1 -i -o $2
   diff -q -w -B $2 expected
 }
 
diff --git a/tools/versioner/tests/preprocessor_file_offset_bits/run.sh b/tools/versioner/tests/preprocessor_file_offset_bits/run.sh
index c503867..d974cba 100644
--- a/tools/versioner/tests/preprocessor_file_offset_bits/run.sh
+++ b/tools/versioner/tests/preprocessor_file_offset_bits/run.sh
@@ -1,5 +1,5 @@
 set -e
 
 rm -rf out
-versioner headers -i -o out
+versioner headers -a 9 -a 12 -a 13 -i -o out
 diff -q -w -B out expected
diff --git a/tools/versioner/tests/preprocessor_merging/run.sh b/tools/versioner/tests/preprocessor_merging/run.sh
index 1b0aae2..1929757 100644
--- a/tools/versioner/tests/preprocessor_merging/run.sh
+++ b/tools/versioner/tests/preprocessor_merging/run.sh
@@ -1,4 +1,4 @@
 rm -rf out
 set -e
-versioner headers -i -o out
+versioner headers -a 9 -a 10 -a 11 -i -o out
 diff -q -w -B out expected