Fix recipes/tests for new Debian bots

Bug: skia:6612
Change-Id: I2920bb7b1aa3ebb021223ed6345f13f1f9c8bc24
Reviewed-on: https://skia-review.googlesource.com/21141
Reviewed-by: Ben Wagner <benjaminwagner@google.com>
Commit-Queue: Eric Boren <borenet@google.com>
diff --git a/gm/textblobrandomfont.cpp b/gm/textblobrandomfont.cpp
index c489bd1..e00b299 100644
--- a/gm/textblobrandomfont.cpp
+++ b/gm/textblobrandomfont.cpp
@@ -69,7 +69,7 @@
         sk_sp<SkTypeface> origEmoji = sk_tool_utils::emoji_typeface();
         const char* osName = sk_tool_utils::platform_os_name();
         // The mac emoji string will break us
-        if (origEmoji && (!strcmp(osName, "Android") || !strcmp(osName, "Ubuntu"))) {
+        if (origEmoji && (!strcmp(osName, "Android") || !strcmp(osName, "Ubuntu") || !strcmp(osName, "Debian"))) {
             const char* emojiText = sk_tool_utils::emoji_sample_text();
             paint.measureText(emojiText, strlen(emojiText), &bounds);
             offset += bounds.height();
diff --git a/infra/bots/infra_tests.py b/infra/bots/infra_tests.py
index a5a26e4..7150e04 100755
--- a/infra/bots/infra_tests.py
+++ b/infra/bots/infra_tests.py
@@ -35,9 +35,11 @@
 
 def recipe_test(train):
   cmd = [
-      'python', os.path.join(INFRA_BOTS_DIR, 'recipes.py'), 'test', 'run']
+      'python', os.path.join(INFRA_BOTS_DIR, 'recipes.py'), 'test']
   if train:
-    cmd.append('--train')
+    cmd.append('train')
+  else:
+    cmd.append('run')
   return test(cmd, SKIA_DIR)
 
 
diff --git a/infra/bots/recipe_modules/flavor/gn_flavor.py b/infra/bots/recipe_modules/flavor/gn_flavor.py
index 0db02dc..9e8a488 100644
--- a/infra/bots/recipe_modules/flavor/gn_flavor.py
+++ b/infra/bots/recipe_modules/flavor/gn_flavor.py
@@ -41,7 +41,7 @@
     extra_cflags = []
     extra_ldflags = []
 
-    if compiler == 'Clang' and os == 'Ubuntu':
+    if compiler == 'Clang' and self.m.vars.is_linux:
       cc  = clang_linux + '/bin/clang'
       cxx = clang_linux + '/bin/clang++'
       extra_cflags .append('-B%s/bin' % clang_linux)
@@ -101,7 +101,7 @@
       args['is_component_build'] = 'true'
     if extra_config == 'Vulkan':
       args['skia_enable_vulkan_debug_layers'] = 'false'
-      if os == 'Ubuntu':
+      if self.m.vars.is_linux:
         args['skia_vulkan_sdk'] = '"%s"' % linux_vulkan_sdk
       if 'Win' in os:
         args['skia_vulkan_sdk'] = '"%s"' % win_vulkan_sdk
@@ -154,7 +154,7 @@
     if 'SAN' in extra_config:
       # Sanitized binaries may want to run clang_linux/bin/llvm-symbolizer.
       env['PATH'] = '%%(PATH)s:%s' % clang_linux + '/bin'
-    elif 'Ubuntu' == self.m.vars.builder_cfg.get('os', ''):
+    elif self.m.vars.is_linux:
       cmd = ['catchsegv'] + cmd
 
     if 'ASAN' == extra_config:
@@ -167,7 +167,7 @@
       env['LD_LIBRARY_PATH'] = clang_linux + '/msan'
 
     to_symbolize = ['dm', 'nanobench']
-    if name in to_symbolize and 'Ubuntu' in self.m.vars.builder_cfg['os']:
+    if name in to_symbolize and self.m.vars.is_linux:
       # Convert path objects or placeholders into strings such that they can
       # be passed to symbolize_stack_trace.py
       args = [self.m.vars.slave_dir] + [str(x) for x in cmd]
diff --git a/infra/bots/recipe_modules/vars/api.py b/infra/bots/recipe_modules/vars/api.py
index 2c23f7a..da11651 100644
--- a/infra/bots/recipe_modules/vars/api.py
+++ b/infra/bots/recipe_modules/vars/api.py
@@ -143,6 +143,10 @@
     self.chromeos_homedir = '/home/chronos/user/'
 
   @property
+  def is_linux(self):
+    return 'Ubuntu' in self.builder_name or 'Debian' in self.builder_name
+
+  @property
   def upload_dm_results(self):
     # TODO(borenet): Move this into the swarm_test recipe.
     skip_upload_bots = [
diff --git a/infra/bots/recipe_modules/vars/examples/full.py b/infra/bots/recipe_modules/vars/examples/full.py
index be15b06..eeddfd7 100644
--- a/infra/bots/recipe_modules/vars/examples/full.py
+++ b/infra/bots/recipe_modules/vars/examples/full.py
@@ -17,7 +17,8 @@
     api.vars.swarming_bot_id,
     api.vars.swarming_task_id,
   ]
-  assert len(info) == 4  # Make pylint happy.
+  if api.vars.is_linux:
+    assert len(info) == 4  # Make pylint happy.
 
 
 TEST_BUILDERS = [
diff --git a/infra/bots/recipes/perf.expected/Perf-Ubuntu16-Clang-NUC6i5SYK-GPU-IntelIris540-x86_64-Debug-Vulkan.json b/infra/bots/recipes/perf.expected/Perf-Ubuntu16-Clang-NUC6i5SYK-GPU-IntelIris540-x86_64-Debug-Vulkan.json
index 5978c31..9a49084 100644
--- a/infra/bots/recipes/perf.expected/Perf-Ubuntu16-Clang-NUC6i5SYK-GPU-IntelIris540-x86_64-Debug-Vulkan.json
+++ b/infra/bots/recipes/perf.expected/Perf-Ubuntu16-Clang-NUC6i5SYK-GPU-IntelIris540-x86_64-Debug-Vulkan.json
@@ -117,6 +117,7 @@
       "-u",
       "RECIPE_MODULE[skia::flavor]/resources/symbolize_stack_trace.py",
       "[START_DIR]",
+      "catchsegv",
       "[START_DIR]/out/Debug/nanobench",
       "--undefok",
       "-i",
diff --git a/infra/bots/recipes/perf.expected/Perf-Ubuntu16-Clang-NUC6i5SYK-GPU-IntelIris540-x86_64-Release.json b/infra/bots/recipes/perf.expected/Perf-Ubuntu16-Clang-NUC6i5SYK-GPU-IntelIris540-x86_64-Release.json
index 909bc17..86344c0 100644
--- a/infra/bots/recipes/perf.expected/Perf-Ubuntu16-Clang-NUC6i5SYK-GPU-IntelIris540-x86_64-Release.json
+++ b/infra/bots/recipes/perf.expected/Perf-Ubuntu16-Clang-NUC6i5SYK-GPU-IntelIris540-x86_64-Release.json
@@ -153,6 +153,7 @@
       "-u",
       "RECIPE_MODULE[skia::flavor]/resources/symbolize_stack_trace.py",
       "[START_DIR]",
+      "catchsegv",
       "[START_DIR]/out/Release/nanobench",
       "--undefok",
       "-i",
diff --git a/infra/bots/recipes/perf.py b/infra/bots/recipes/perf.py
index f7f6dba..3e8e78e 100644
--- a/infra/bots/recipes/perf.py
+++ b/infra/bots/recipes/perf.py
@@ -26,7 +26,7 @@
 ]
 
 
-def nanobench_flags(bot):
+def nanobench_flags(api, bot):
   args = ['--pre_log']
 
   if 'GPU' in bot:
@@ -74,7 +74,7 @@
 
   # We want to test both the OpenGL config and the GLES config on Linux Intel:
   # GL is used by Chrome, GLES is used by ChromeOS.
-  if 'Intel' in bot and 'Ubuntu' in bot:
+  if 'Intel' in bot and api.vars.is_linux:
     configs.append('gles')
 
   # Bench instanced rendering on a limited number of platforms
@@ -148,7 +148,7 @@
     match.append('~text_16_LCD_BK')
     match.append('~text_16_LCD_FF')
     match.append('~text_16_LCD_WT')
-  if 'Intel' in bot and 'Ubuntu' in bot and not 'Vulkan' in bot:
+  if ('Intel' in bot and api.vars.is_linux and not 'Vulkan' in bot):
     # TODO(dogben): Track down what's causing bots to die.
     verbose = True
   if 'Vulkan' in bot and 'NexusPlayer' in bot:
@@ -241,7 +241,7 @@
     skip_flag = '--nocpu'
   if skip_flag:
     args.append(skip_flag)
-  args.extend(nanobench_flags(api.vars.builder_name))
+  args.extend(nanobench_flags(api, api.vars.builder_name))
 
   if 'Chromecast' in api.vars.builder_cfg.get('os', ''):
     # Due to limited disk space, run a watered down perf run on Chromecast.
diff --git a/infra/bots/recipes/test.expected/Test-Ubuntu16-Clang-NUC5PPYH-GPU-IntelHD405-x86_64-Debug.json b/infra/bots/recipes/test.expected/Test-Ubuntu16-Clang-NUC5PPYH-GPU-IntelHD405-x86_64-Debug.json
index 7ca47b5..23c85cd 100644
--- a/infra/bots/recipes/test.expected/Test-Ubuntu16-Clang-NUC5PPYH-GPU-IntelHD405-x86_64-Debug.json
+++ b/infra/bots/recipes/test.expected/Test-Ubuntu16-Clang-NUC5PPYH-GPU-IntelHD405-x86_64-Debug.json
@@ -225,6 +225,7 @@
       "-u",
       "RECIPE_MODULE[skia::flavor]/resources/symbolize_stack_trace.py",
       "[START_DIR]",
+      "catchsegv",
       "[START_DIR]/out/Debug/dm",
       "--undefok",
       "--resourcePath",
diff --git a/infra/bots/recipes/test.expected/Test-Ubuntu16-Clang-NUC6i5SYK-GPU-IntelIris540-x86_64-Debug-Vulkan.json b/infra/bots/recipes/test.expected/Test-Ubuntu16-Clang-NUC6i5SYK-GPU-IntelIris540-x86_64-Debug-Vulkan.json
index 9d718f8..6a3e84c 100644
--- a/infra/bots/recipes/test.expected/Test-Ubuntu16-Clang-NUC6i5SYK-GPU-IntelIris540-x86_64-Debug-Vulkan.json
+++ b/infra/bots/recipes/test.expected/Test-Ubuntu16-Clang-NUC6i5SYK-GPU-IntelIris540-x86_64-Debug-Vulkan.json
@@ -225,6 +225,7 @@
       "-u",
       "RECIPE_MODULE[skia::flavor]/resources/symbolize_stack_trace.py",
       "[START_DIR]",
+      "catchsegv",
       "[START_DIR]/out/Debug/dm",
       "--undefok",
       "--resourcePath",
diff --git a/infra/bots/recipes/test.expected/Test-Ubuntu16-Clang-NUC6i5SYK-GPU-IntelIris540-x86_64-Release.json b/infra/bots/recipes/test.expected/Test-Ubuntu16-Clang-NUC6i5SYK-GPU-IntelIris540-x86_64-Release.json
index b87a0e4..227bb7e 100644
--- a/infra/bots/recipes/test.expected/Test-Ubuntu16-Clang-NUC6i5SYK-GPU-IntelIris540-x86_64-Release.json
+++ b/infra/bots/recipes/test.expected/Test-Ubuntu16-Clang-NUC6i5SYK-GPU-IntelIris540-x86_64-Release.json
@@ -225,6 +225,7 @@
       "-u",
       "RECIPE_MODULE[skia::flavor]/resources/symbolize_stack_trace.py",
       "[START_DIR]",
+      "catchsegv",
       "[START_DIR]/out/Release/dm",
       "--undefok",
       "--resourcePath",
diff --git a/infra/bots/recipes/test.expected/Test-Ubuntu16-Clang-NUCDE3815TYKHE-GPU-IntelBayTrail-x86_64-Debug.json b/infra/bots/recipes/test.expected/Test-Ubuntu16-Clang-NUCDE3815TYKHE-GPU-IntelBayTrail-x86_64-Debug.json
index 5dac619..b3f0b33 100644
--- a/infra/bots/recipes/test.expected/Test-Ubuntu16-Clang-NUCDE3815TYKHE-GPU-IntelBayTrail-x86_64-Debug.json
+++ b/infra/bots/recipes/test.expected/Test-Ubuntu16-Clang-NUCDE3815TYKHE-GPU-IntelBayTrail-x86_64-Debug.json
@@ -225,6 +225,7 @@
       "-u",
       "RECIPE_MODULE[skia::flavor]/resources/symbolize_stack_trace.py",
       "[START_DIR]",
+      "catchsegv",
       "[START_DIR]/out/Debug/dm",
       "--undefok",
       "--resourcePath",
diff --git a/infra/bots/recipes/test.py b/infra/bots/recipes/test.py
index b05ea5f..e2a42d9 100644
--- a/infra/bots/recipes/test.py
+++ b/infra/bots/recipes/test.py
@@ -24,7 +24,7 @@
 ]
 
 
-def dm_flags(bot):
+def dm_flags(api, bot):
   args = []
 
   # This enables non-deterministic random seeding of the GPU FP optimization
@@ -103,7 +103,7 @@
 
   # We want to test both the OpenGL config and the GLES config on Linux Intel:
   # GL is used by Chrome, GLES is used by ChromeOS.
-  if 'Intel' in bot and 'Ubuntu' in bot:
+  if 'Intel' in bot and api.vars.is_linux:
     configs.extend(['gles', 'glesdft', 'glessrgb'])
 
   # NP is running out of RAM when we run all these modes.  skia:3255
@@ -442,10 +442,10 @@
                   '~bitmapfilters', # skia:6132
                   '~GrContextFactory_abandon']) #skia:6209
 
-  if 'Vulkan' in bot and 'IntelIris540' in bot and 'Ubuntu' in bot:
+  if 'Vulkan' in bot and 'IntelIris540' in bot and api.vars.is_linux:
     match.extend(['~VkHeapTests']) # skia:6245
 
-  if 'Intel' in bot and 'Ubuntu' in bot and not 'Vulkan' in bot:
+  if 'Intel' in bot and api.vars.is_linux and not 'Vulkan' in bot:
     # TODO(dogben): Track down what's causing bots to die.
     verbose = True
 
@@ -530,7 +530,7 @@
       # skia:6141
       blacklist([config, 'gm', '_', 'discard'])
 
-  if 'IntelBayTrail' in bot and 'Ubuntu' in bot:
+  if 'IntelBayTrail' in bot and api.vars.is_linux:
     match.append('~ImageStorageLoad') # skia:6358
 
   if 'Ci20' in bot:
@@ -700,7 +700,7 @@
     skip_flag = '--nocpu'
   if skip_flag:
     args.append(skip_flag)
-  args.extend(dm_flags(api.vars.builder_name))
+  args.extend(dm_flags(api, api.vars.builder_name))
 
   env = {}
   if 'Ubuntu16' in api.vars.builder_name:
diff --git a/tools/sk_tool_utils.cpp b/tools/sk_tool_utils.cpp
index c792c48..ba1f534 100644
--- a/tools/sk_tool_utils.cpp
+++ b/tools/sk_tool_utils.cpp
@@ -90,7 +90,7 @@
     if (platform.equals("Win")) {
         return gStandardFontNames[2][index];
     }
-    if (platform.equals("Ubuntu")) {
+    if (platform.equals("Ubuntu") || platform.equals("Debian")) {
         return gStandardFontNames[3][index];
     }
     if (platform.equals("Android")) {
@@ -104,7 +104,7 @@
 
 const char* platform_os_emoji() {
     const char* osName = platform_os_name();
-    if (!strcmp(osName, "Android") || !strcmp(osName, "Ubuntu")) {
+    if (!strcmp(osName, "Android") || !strcmp(osName, "Ubuntu") || !strcmp(osName, "Debian")) {
         return "CBDT";
     }
     if (!strncmp(osName, "Mac", 3) || !strncmp(osName, "iOS", 3)) {