Fix invalid constant error reporting.

zentaro@ pointed out it's hard to debug syscall policy failures when
using an unrecognized constant.

Print an error when reading an invalid argument index, an invalid
constant, or an invalid errno value.

Bug: 32236891
Test: syscall_filter_unittest
Change-Id: Ifb20efcd9b107ca240ab37ac5e3ed501f55d6dea
diff --git a/syscall_filter_unittest.cpp b/syscall_filter_unittest.cpp
index 403c10d..2445f0a 100644
--- a/syscall_filter_unittest.cpp
+++ b/syscall_filter_unittest.cpp
@@ -586,18 +586,34 @@
   free_block_list(block);
 }
 
-TEST_F(ArgFilterTest, invalid) {
+TEST_F(ArgFilterTest, invalid_arg_number) {
   const char *fragment = "argnn == 0";
   int nr = 1;
   unsigned int id = 0;
 
   struct filter_block *block =
       compile_section(nr, fragment, id, &labels_, NO_LOGGING);
-  ASSERT_TRUE(block == NULL);
+  ASSERT_EQ(block, nullptr);
+}
 
-  fragment = "arg0 == 0 && arg1 == 1; return errno";
-  block = compile_section(nr, fragment, id, &labels_, NO_LOGGING);
-  ASSERT_TRUE(block == NULL);
+TEST_F(ArgFilterTest, invalid_constant) {
+  const char *fragment = "arg0 == INVALIDCONSTANT";
+  int nr = 1;
+  unsigned int id = 0;
+
+  struct filter_block* block =
+      compile_section(nr, fragment, id, &labels_, NO_LOGGING);
+  ASSERT_EQ(block, nullptr);
+}
+
+TEST_F(ArgFilterTest, invalid_errno) {
+  const char *fragment = "arg0 == 0 && arg1 == 1; return errno";
+  int nr = 1;
+  unsigned int id = 0;
+
+  struct filter_block *block =
+      compile_section(nr, fragment, id, &labels_, NO_LOGGING);
+  ASSERT_EQ(block, nullptr);
 }
 
 TEST_F(ArgFilterTest, log_no_ret_error) {