bluetooth autotest: Additional check in bluetooth_PeerUpdate

bluetooth_PeerUpdate needs to check noexec status of /tmp partition

TEST=Ran on RPI and FIZZ
BUG=b:146437436

Change-Id: Id16ecef278f5e5af476b41ad1d9c1f1b66b1184f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/autotest/+/1984602
Reviewed-by: Shijin Abraham <shijinabraham@google.com>
Reviewed-by: Daniel Winkler <danielwinkler@google.com>
Commit-Queue: Shijin Abraham <shijinabraham@google.com>
Tested-by: Shijin Abraham <shijinabraham@google.com>
diff --git a/server/site_tests/bluetooth_PeerUpdate/bluetooth_PeerUpdate.py b/server/site_tests/bluetooth_PeerUpdate/bluetooth_PeerUpdate.py
index f230abb..f0404f4 100644
--- a/server/site_tests/bluetooth_PeerUpdate/bluetooth_PeerUpdate.py
+++ b/server/site_tests/bluetooth_PeerUpdate/bluetooth_PeerUpdate.py
@@ -113,10 +113,43 @@
         raise error.TestFail("Peer has a higher version")
 
 
+def is_tmp_noexec(peer):
+    """Check if /tmp partition is not excutable."""
+    try:
+        cmd = 'cat /proc/mounts |grep "/tmp"'
+        status, output = run_cmd(peer, cmd)
+        return status and 'noexec' in output
+    except Exception as e:
+        logging.error('Exception %s while checking status of /tmp', str(e))
+        return True
 
-def perform_update(peer):
+def remount_tmp_exec(peer):
+    """Remount /tmp partition with exec flag."""
+    try:
+        cmd = 'mount -o remount,exec "/tmp"'
+        status, output = run_cmd(peer, cmd)
+        return status
+    except Exception as e:
+        logging.error('Exception %s while remounting /tmp', str(e))
+        return False
+
+
+
+def perform_update(peer, arch):
     """ Update the chameleond on the peer"""
 
+    if arch == 'CHROMEOS':
+        logging.info("Check if /tmp partition is executable")
+        if is_tmp_noexec(peer):
+            if not remount_tmp_exec(peer):
+                logging.error("unable to remount /tmp as exec")
+                return False
+            if is_tmp_noexec(peer):
+                logging.error("/tmp partition is still noexec")
+                return False
+        logging.info("/tmp partition is executable")
+
+
     logging.info("copy the file over to the peer")
     try:
         current_dir = os.path.dirname(os.path.realpath(__file__))
@@ -194,7 +227,7 @@
     if not is_update_needed(peer):
         raise error.TestNAError("Update not needed")
 
-    if not perform_update(peer):
+    if not perform_update(peer, arch):
         raise error.TestFail("Update failed")
 
     if not restart_check_chameleond(peer, arch):