Merge change 5449
* changes:
init: set permissions for akm8973 and bma150 drivers
diff --git a/libacc/tests/test b/libacc/tests/test
new file mode 100755
index 0000000..ef10500
--- /dev/null
+++ b/libacc/tests/test
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+SCRIPT_DIR=`dirname $BASH_SOURCE`
+cd $SCRIPT_DIR
+python test.py
+
diff --git a/libacc/tests/test.py b/libacc/tests/test.py
new file mode 100644
index 0000000..ef5963b
--- /dev/null
+++ b/libacc/tests/test.py
@@ -0,0 +1,114 @@
+#
+# Test the acc compiler
+
+import unittest
+import subprocess
+import os
+
+def compile(args):
+ proc = subprocess.Popen(["acc"] + args, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
+ result = proc.communicate()
+ return result
+
+def runCmd(args):
+ proc = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ result = proc.communicate()
+ return result[0].strip()
+
+def which(item):
+ return runCmd(["which", item])
+
+def fileType(item):
+ return runCmd(["file", item])
+
+def outputCanRun():
+ ft = fileType(which("acc"))
+ return ft.find("ELF 32-bit LSB executable, Intel 80386") >= 0
+
+def adb(args):
+ return runCmd(["adb"] + args)
+
+gArmInitialized = False
+
+def setupArm():
+ if gArmInitialized:
+ return
+ print "Setting up arm"
+ adb(["remount"])
+ adb(["shell", "rm", "/system/bin/acc"])
+ adb(["shell", "mkdir", "/system/bin/accdata"])
+ adb(["shell", "mkdir", "/system/bin/accdata/data"])
+ # Clear out old data TODO: handle recursion
+ adb(["shell", "rm", "/system/bin/accdata/data/*"])
+ # Copy over data
+ for root, dirs, files in os.walk("data"):
+ for d in dirs:
+ adb(["shell", "mkdir", os.path.join(root, d)])
+ for f in files:
+ adb(["push", os.path.join(root, f), os.path.join("/system/bin/accdata", root, f)])
+ # Copy over compiler
+ adb(["sync"])
+ gArmInitialied = True
+
+def compileArm(args):
+ setupArm()
+ proc = subprocess.Popen(["adb", "shell", "/system/bin/acc"] + args, stdout=subprocess.PIPE)
+ result = proc.communicate()
+ return result[0].replace("\r","")
+
+def compare(a, b):
+ if a != b:
+ firstDiff = firstDifference(a,b)
+ print "Strings differ at character", firstDiff, a[firstDiff], b[firstDiff]
+
+def firstDifference(a, b):
+ commonLen = min(len(a), len(b))
+ for i in xrange(0, commonLen):
+ if a[i] != b[i]:
+ return i
+ return commonLen
+
+class TestACC(unittest.TestCase):
+
+ def compileCheck(self, args, stdErrResult, stdOutResult=""):
+ out, err = compile(args)
+ compare(out, stdOutResult)
+ compare(err, stdErrResult)
+ self.assertEqual(out, stdOutResult)
+ self.assertEqual(err, stdErrResult)
+
+ def compileCheckArm(self, args, result):
+ self.assertEqual(compileArm(args), result)
+
+ def testCompileReturnVal(self):
+ self.compileCheck(["data/returnval-ansi.c"], "")
+
+ def testCompileReturnVal(self):
+ self.compileCheck(["data/otcc-ansi.c"], "")
+
+ def testRunReturnVal(self):
+ self.compileCheck(["-R", "data/returnval-ansi.c"],
+ "Executing compiled code:\nresult: 42\n")
+ def testRunOTCCANSI(self):
+ self.compileCheck(["-R", "data/otcc-ansi.c", "data/returnval.c"],
+ "Executing compiled code:\notcc-ansi.c: About to execute compiled code:\natcc-ansi.c: result: 42\nresult: 42\n")
+
+ def testRunOTCCANSI2(self):
+ self.compileCheck(["-R", "data/otcc-ansi.c", "data/otcc.c", "data/returnval.c"],
+ "Executing compiled code:\notcc-ansi.c: About to execute compiled code:\notcc.c: about to execute compiled code.\natcc-ansi.c: result: 42\nresult: 42\n")
+
+ def testRunConstants(self):
+ self.compileCheck(["-R", "data/constants.c"],
+ "Executing compiled code:\nresult: 12\n",
+ "0 = 0\n010 = 8\n0x10 = 16\n'\\a' = 7\n'\\b' = 8\n'\\f' = 12\n'\\n' = 10\n'\\r' = 13\n'\\t' = 9\n'\\v' = 11\n'\\\\' = 92\n'\\'' = 39\n" +
+ "'\\\"' = 34\n'\\?' = 63\n'\\0' = 0\n'\\1' = 1\n'\\12' = 10\n'\\123' = 83\n'\\x0' = 0\n'\\x1' = 1\n'\\x12' = 18\n'\\x123' = 291\n'\\x1f' = 31\n'\\x1F' = 31\n")
+
+ def testArmRunReturnVal(self):
+ self.compileCheckArm(["-R", "/system/bin/accdata/data/returnval-ansi.c"],
+ "Executing compiled code:\nresult: 42\n")
+
+if __name__ == '__main__':
+ if not outputCanRun():
+ print "Many tests are expected to fail, because acc is not a 32-bit x86 Linux executable."
+ unittest.main()
+
diff --git a/libacc/tests/testarm b/libacc/tests/testarm
deleted file mode 100755
index 1d4b866..0000000
--- a/libacc/tests/testarm
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/sh
-adb remount
-adb shell rm /system/bin/acc
-adb push data/returnval-ansi.c /system/bin/returnval-ansi.c
-cd ..
-mm -j8
-cd tests
-adb sync
-adb shell /system/bin/acc -R -S /system/bin/returnval-ansi.c
diff --git a/libacc/tests/testlocal b/libacc/tests/testlocal
deleted file mode 100755
index 1a0b4c5..0000000
--- a/libacc/tests/testlocal
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/bash
-
-SCRIPT_DIR=`dirname $BASH_SOURCE`
-DATA=$SCRIPT_DIR/data
-ACC=`which acc`
-
-echo "Compiling returnval-ansi.c"
-$ACC -S $DATA/returnval-ansi.c
-
-echo "Compiling whole compiler."
-$ACC -S "$DATA/otcc-ansi.c"
-
-if file $ACC | grep -q "ELF 32-bit LSB executable, Intel 80386"; then
- echo "Linux 32bit Intel."
- echo "TESTING returnval-ansi.c:"
- $ACC -R $DATA/returnval-ansi.c
- echo TESTING otcc-ansi.c returnval-ansi.c
- $ACC -R "$DATA/otcc-ansi.c" "$DATA/returnval.c"
- echo TESTING otcc-ansi.c otcc.c returnval-ansi.c
- $ACC -R $DATA/otcc-ansi.c $DATA/otcc.c $DATA/returnval.c
-fi
-
-echo "Done with tests."
diff --git a/vold/logwrapper.c b/vold/logwrapper.c
index 46f6ed3..8da4892 100644
--- a/vold/logwrapper.c
+++ b/vold/logwrapper.c
@@ -42,7 +42,8 @@
buffer[b] = '\0';
} else if (buffer[b] == '\n') {
buffer[b] = '\0';
- LOG(LOG_INFO, tag, &buffer[a]);
+
+ LOG(LOG_INFO, tag, "%s", &buffer[a]);
a = b + 1;
}
}
diff --git a/vold/volmgr_vfat.c b/vold/volmgr_vfat.c
index 7833222..7a4e12f 100644
--- a/vold/volmgr_vfat.c
+++ b/vold/volmgr_vfat.c
@@ -26,7 +26,7 @@
#define VFAT_DEBUG 0
-static char FSCK_MSDOS_PATH[] = "/system/bin/dosfsck";
+static char FSCK_MSDOS_PATH[] = "/system/bin/fsck_msdos";
int vfat_identify(blkdev_t *dev)
{
@@ -51,51 +51,28 @@
return 0;
}
- do {
+ char *args[5];
+ args[0] = FSCK_MSDOS_PATH;
+ args[1] = "-p";
+ args[2] = "-f";
+ args[3] = blkdev_get_devpath(dev);
+ args[4] = NULL;
+ rc = logwrap(4, args, 1);
+ free(args[3]);
- char *args[6];
- args[0] = FSCK_MSDOS_PATH;
- args[1] = "-v";
-
- if (rw) {
- args[2] = "-w";
- args[3] = "-p";
- args[4] = blkdev_get_devpath(dev);
- args[5] = NULL;
- rc = logwrap(5, args, 1);
- free(args[4]);
- } else {
- args[2] = "-n";
- args[3] = blkdev_get_devpath(dev);
- args[4] = NULL;
- rc = logwrap(4, args, 1);
- free(args[3]);
- }
-
- if (rc == 0) {
- LOG_VOL("Filesystem check completed OK");
- return 0;
- } else if (rc == 1) {
- LOG_VOL("Filesystem check failed (general failure)");
- return -EINVAL;
- } else if (rc == 2) {
- LOG_VOL("Filesystem check failed (invalid usage)");
- return -EIO;
- } else if (rc == 4) {
- LOG_VOL("Filesystem check completed (errors fixed)");
- } else if (rc == 6) {
- LOG_VOL("Filesystem read-only - retrying check RO");
- rw = false;
- continue;
- } else if (rc == 8) {
- LOG_VOL("Filesystem check failed (not a FAT filesystem)");
- return -ENODATA;
- } else {
- LOG_VOL("Filesystem check failed (unknown exit code %d)", rc);
- return -EIO;
- }
- } while (0);
-
+ if (rc == 0) {
+ LOG_VOL("Filesystem check completed OK");
+ return 0;
+ } else if (rc == 2) {
+ LOG_VOL("Filesystem check failed (not a FAT filesystem)");
+ return -ENODATA;
+ } else if (rc == -11) {
+ LOG_VOL("Filesystem check crashed");
+ return -EIO;
+ } else {
+ LOG_VOL("Filesystem check failed (unknown exit code %d)", rc);
+ return -EIO;
+ }
return 0;
}