From 4904c6cf71e225b449ee966655ef1d672e34a89b Mon Sep 17 00:00:00 2001
From: Sergei Trofimov <sergei.trofimov@arm.com>
Date: Mon, 29 Jun 2015 11:28:47 +0100
Subject: [PATCH] listdir on Linux: return empty list for an empty directory

Previously, was returning a list with a single empty string element
---
 wlauto/common/linux/device.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/wlauto/common/linux/device.py b/wlauto/common/linux/device.py
index 5c40db99..6e2364ab 100644
--- a/wlauto/common/linux/device.py
+++ b/wlauto/common/linux/device.py
@@ -719,7 +719,9 @@ class LinuxDevice(BaseLinuxDevice):
         return boolean(output.split()[-1])  # pylint: disable=maybe-no-member
 
     def listdir(self, path, as_root=False, **kwargs):
-        contents = self.execute('ls -1 {}'.format(path), as_root=as_root)
+        contents = self.execute('ls -1 {}'.format(path), as_root=as_root).strip()
+        if not contents:
+            return []
         return [x.strip() for x in contents.split('\n')]  # pylint: disable=maybe-no-member
 
     def install(self, filepath, timeout=default_timeout, with_name=None):  # pylint: disable=W0221