crosperf: fix a bug where we tar the world in results_cache

This consumes potentially tons of disk. Also we'll raise in this
situation from now on, since it never seems to be what we want.

BUG=chromium:1079048
TEST=Unittests

Change-Id: Ie1933b5ff0b939777d7e1d6d35dd5a29039ca07a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/2220291
Reviewed-by: Zhizhou Yang <zhizhouy@google.com>
Tested-by: George Burgess <gbiv@chromium.org>
diff --git a/crosperf/results_cache.py b/crosperf/results_cache.py
index 0dd60ea..b208ef9 100644
--- a/crosperf/results_cache.py
+++ b/crosperf/results_cache.py
@@ -124,6 +124,11 @@
     result_dir_name = self.test_name if self.suite == 'tast' else 'results'
     results_dir = self.FindFilesInResultsDir(
         '-name %s' % result_dir_name).split('\n')[0]
+
+    if not results_dir:
+      self._logger.LogOutput(
+          'WARNING: No results dir matching %r found' % result_dir_name)
+
     self.CreateTarball(results_dir, tarball)
     self.CopyFilesTo(dest_dir, [tarball])
     if results_dir:
@@ -921,6 +926,10 @@
       self.ce.RunCommand(command)
 
   def CreateTarball(self, results_dir, tarball):
+    if not results_dir.strip():
+      raise ValueError(
+          'Refusing to `tar` an empty results_dir: %r' % results_dir)
+
     ret = self.ce.RunCommand('cd %s && '
                              'tar '
                              '--exclude=var/spool '