For bootstat_get_last, don't complain about non-existent events.

Requested events are converted into files to be processed by
'tail -1'.  If the file doesn't exist, tail complains.  We don't
want the complaint, because this command is meant to be used to test
for non-existent events.

BUG=chromium-os:32203
TEST=run the test from the bug report

Change-Id: I0c76f531e84ad71470394793cc1e2cdfe977e3df
Reviewed-on: https://gerrit.chromium.org/gerrit/26271
Reviewed-by: Daniel Erat <derat@chromium.org>
Tested-by: Richard Barnette <jrbarnette@chromium.org>
Commit-Ready: Richard Barnette <jrbarnette@chromium.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
diff --git a/bootstat_get_last b/bootstat_get_last
index 04b4781..2dc5592 100755
--- a/bootstat_get_last
+++ b/bootstat_get_last
@@ -1,6 +1,5 @@
 #!/bin/sh
-
-# Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
+# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
@@ -34,6 +33,12 @@
       continue
     ;;
   esac
-  getfield $FIELD $(tail -1 /tmp/${TAG}-${EVENT})
+  # The 'boot-complete' upstart job tests for whether an event has
+  # been recorded by calling this script, so it's not an error if
+  # the requested event doesn't exist.
+  EVENTFILE="/tmp/${TAG}-${EVENT}"
+  if [ -f "$EVENTFILE" ]; then
+    getfield $FIELD $(tail -1 "$EVENTFILE")
+  fi
   shift
 done