diff options
author | binji@chromium.org <binji@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-09 20:40:23 +0000 |
---|---|---|
committer | binji@chromium.org <binji@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-09 20:40:23 +0000 |
commit | 6a40ddad00cc5c1a329c39605633c818782b84ad (patch) | |
tree | fb38e1ef89ba4ba387b136dba0b5c317aaf6efac /native_client_sdk/src | |
parent | 0b7016747ea862405f2062d493d01ff8a6dae3c4 (diff) | |
download | chromium_src-6a40ddad00cc5c1a329c39605633c818782b84ad.zip chromium_src-6a40ddad00cc5c1a329c39605633c818782b84ad.tar.gz chromium_src-6a40ddad00cc5c1a329c39605633c818782b84ad.tar.bz2 |
[NaCl SDK] Get nacl_mounts_tests building.
BUG=none
NOTRY=true
Review URL: https://chromiumcodereview.appspot.com/10825189
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@150893 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'native_client_sdk/src')
14 files changed, 149 insertions, 99 deletions
diff --git a/native_client_sdk/src/build_tools/build_sdk.py b/native_client_sdk/src/build_tools/build_sdk.py index a40afa3..4eafb89 100755 --- a/native_client_sdk/src/build_tools/build_sdk.py +++ b/native_client_sdk/src/build_tools/build_sdk.py @@ -536,12 +536,12 @@ def GetWindowsEnvironment(): return dict(line.split('=') for line in stdout.split('\r\n')[:-1]) -def BuildStepBuildLibraries(pepperdir, platform, directory): - buildbot_common.BuildStep('Build Libraries') - src_dir = os.path.join(pepperdir, directory) - makefile = os.path.join(src_dir, 'Makefile') +def BuildStepMakeAll(pepperdir, platform, directory, step_name, clean=False): + buildbot_common.BuildStep(step_name) + make_dir = os.path.join(pepperdir, directory) + makefile = os.path.join(make_dir, 'Makefile') if os.path.isfile(makefile): - print "\n\nMake: " + src_dir + print "\n\nMake: " + make_dir if platform == 'win': # We need to modify the environment to build host on Windows. env = GetWindowsEnvironment() @@ -549,10 +549,16 @@ def BuildStepBuildLibraries(pepperdir, platform, directory): env = os.environ buildbot_common.Run(['make', '-j8'], - cwd=os.path.abspath(src_dir), shell=True, env=env) - # Clean to remove temporary files but keep the built libraries. - buildbot_common.Run(['make', '-j8', 'clean'], - cwd=os.path.abspath(src_dir), shell=True) + cwd=os.path.abspath(make_dir), shell=True, env=env) + if clean: + # Clean to remove temporary files but keep the built libraries. + buildbot_common.Run(['make', '-j8', 'clean'], + cwd=os.path.abspath(make_dir), shell=True) + + +def BuildStepBuildLibraries(pepperdir, platform, directory): + BuildStepMakeAll(pepperdir, platform, directory, 'Build Libraries', + clean=True) def BuildStepTarBundle(pepper_ver, tarfile): @@ -619,21 +625,11 @@ def BuildStepTestUpdater(platform, pepper_ver, revision, tarfile): def BuildStepBuildExamples(pepperdir, platform): - buildbot_common.BuildStep('Build Examples') - example_dir = os.path.join(pepperdir, 'examples') - makefile = os.path.join(example_dir, 'Makefile') - if os.path.isfile(makefile): - print "\n\nMake: " + example_dir - if platform == 'win': - # We need to modify the environment to build host on Windows. - env = GetWindowsEnvironment() - else: - env = os.environ + BuildStepMakeAll(pepperdir, platform, 'examples', 'Build Examples') - buildbot_common.Run(['make', '-j8'], - cwd=os.path.abspath(example_dir), shell=True, env=env) TEST_EXAMPLE_LIST = [ + 'nacl_mounts_test', ] TEST_LIBRARY_LIST = [ @@ -651,14 +647,14 @@ def BuildStepCopyTests(pepperdir, toolchains, build_experimental): for toolchain in toolchains: args.append('--' + toolchain) - for example in TEST_EXAMPLE_LIST: - dsc = os.path.join(SDK_EXAMPLE_DIR, example, 'example.dsc') - args.append(dsc) - for library in TEST_LIBRARY_LIST: dsc = os.path.join(SDK_LIBRARY_DIR, library, 'library.dsc') args.append(dsc) + for example in TEST_EXAMPLE_LIST: + dsc = os.path.join(SDK_LIBRARY_DIR, example, 'example.dsc') + args.append(dsc) + if build_experimental: args.append('--experimental') @@ -666,7 +662,11 @@ def BuildStepCopyTests(pepperdir, toolchains, build_experimental): buildbot_common.ErrorExit('Failed to build tests.') -def BuildStepTestExamples(pepperdir, platform, pepper_ver): +def BuildStepBuildTests(pepperdir, platform): + BuildStepMakeAll(pepperdir, platform, 'testing', 'Build Tests') + + +def BuildStepRunPyautoTests(pepperdir, platform, pepper_ver): buildbot_common.BuildStep('Test Examples') env = copy.copy(os.environ) env['PEPPER_VER'] = pepper_ver @@ -794,9 +794,9 @@ def main(args): BuildStepBuildLibraries(pepperdir, platform, 'src') BuildStepBuildExamples(pepperdir, platform) BuildStepCopyTests(pepperdir, toolchains, options.build_experimental) - BuildStepBuildLibraries(pepperdir, platform, 'testing') + BuildStepBuildTests(pepperdir, platform) if options.test_examples: - BuildStepTestExamples(pepperdir, platform, pepper_ver) + BuildStepRunPyautoTests(pepperdir, platform, pepper_ver) elif options.only_updater: build_updater.BuildUpdater(OUT_DIR) else: # Build everything. @@ -824,9 +824,9 @@ def main(args): pepperdir = BuildStepTestUpdater(platform, pepper_ver, clnumber, tarfile) BuildStepBuildExamples(pepperdir, platform) BuildStepCopyTests(pepperdir, toolchains, options.build_experimental) - BuildStepBuildLibraries(pepperdir, platform, 'testing') + BuildStepBuildTests(pepperdir, platform) if options.test_examples: - BuildStepTestExamples(pepperdir, platform, pepper_ver) + BuildStepRunPyautoTests(pepperdir, platform, pepper_ver) # Archive on non-trybots. if options.archive or buildbot_common.IsSDKBuilder(): diff --git a/native_client_sdk/src/build_tools/make_rules.py b/native_client_sdk/src/build_tools/make_rules.py index e82b85d..a24e8c8 100755 --- a/native_client_sdk/src/build_tools/make_rules.py +++ b/native_client_sdk/src/build_tools/make_rules.py @@ -55,13 +55,13 @@ WIN_CCFLAGS=/I$(NACL_SDK_ROOT)/include /I$(NACL_SDK_ROOT)/include/win -D WIN32 - # CC_RULE = '<tc>/<config>/<name>_<ARCH>.o : %.<ext> $(THIS_MAKE) | <tc>/<config>' NACL_CC_RULES = { - 'Debug': '<TAB>$(<CC>) -o $@ $< -g -O0 <MACH> $(<PROJ>_<EXT>FLAGS) -DTCNAME=<tc> $(<TC>_CCFLAGS) <DEFLIST> <INCLIST>', - 'Release': '<TAB>$(<CC>) -o $@ $< -O2 <MACH> $(<PROJ>_<EXT>FLAGS) -DTCNAME=<tc> $(<TC>_CCFLAGS) <DEFLIST> <INCLIST>', + 'Debug': '<TAB>$(<CC>) -o $@ $< -g -O0 <MACH> -DTCNAME=<tc> $(<TC>_CCFLAGS) $(<PROJ>_<EXT>FLAGS) <DEFLIST> <INCLIST>', + 'Release': '<TAB>$(<CC>) -o $@ $< -O2 <MACH> -DTCNAME=<tc> $(<TC>_CCFLAGS) $(<PROJ>_<EXT>FLAGS) <DEFLIST> <INCLIST>', } SO_CC_RULES = { - 'Debug': '<TAB>$(<CC>) -o $@ $< -g -O0 <MACH> -fPIC $(<PROJ>_<EXT>FLAGS) -DTCNAME=<tc> $(<TC>_CCFLAGS) <DEFLIST> <INCLIST>', - 'Release': '<TAB>$(<CC>) -o $@ $< -02 <MACH> -fPIC $(<PROJ>_<EXT>FLAGS) -DTCNAME=<tc> $(<TC>_CCFLAGS) <DEFLIST> <INCLIST>' + 'Debug': '<TAB>$(<CC>) -o $@ $< -g -O0 <MACH> -fPIC -DTCNAME=<tc> $(<TC>_CCFLAGS) $(<PROJ>_<EXT>FLAGS) <DEFLIST> <INCLIST>', + 'Release': '<TAB>$(<CC>) -o $@ $< -02 <MACH> -fPIC -DTCNAME=<tc> $(<TC>_CCFLAGS) $(<PROJ>_<EXT>FLAGS) <DEFLIST> <INCLIST>' } WIN_CC_RULES = { @@ -73,13 +73,13 @@ WIN_CC_RULES = { # Link rules for various platforms. # NEXE_LINK_RULES = { - 'Debug': '<TAB>$(<LINK>) -o $@ $^ -g <MACH> $(<PROJ>_LDFLAGS) $(<TC>_LDFLAGS) <LIBLIST>', - 'Release': '<TAB>$(<LINK>) -o $@ $^ <MACH> $(<PROJ>_LDFLAGS) $(<TC>_LDFLAGS) <LIBLIST>' + 'Debug': '<TAB>$(<LINK>) -o $@ $^ -g <MACH> $(<TC>_LDFLAGS) $(<PROJ>_LDFLAGS) -L$(NACL_SDK_ROOT)/lib/$(OSNAME)_<ARCH>_<tc>/<config> <LIBLIST>', + 'Release': '<TAB>$(<LINK>) -o $@ $^ <MACH> $(<TC>_LDFLAGS) $(<PROJ>_LDFLAGS) -L$(NACL_SDK_ROOT)/lib/$(OSNAME)_<ARCH>_<tc>/<config> <LIBLIST>' } SO_LINK_RULES = { - 'Debug': '<TAB>$(<LINK>) -o $@ $^ -g <MACH> -shared $(<PROJ>_LDFLAGS) <LIBLIST>', - 'Release': '<TAB>$(<LINK>) -o $@ $^ <MACH> -shared $(<PROJ>_LDFLAGS) <LIBLIST>', + 'Debug': '<TAB>$(<LINK>) -o $@ $^ -g <MACH> -shared $(<PROJ>_LDFLAGS) -L$(NACL_SDK_ROOT)/lib/$(OSNAME)_<ARCH>_<tc>/<config> <LIBLIST>', + 'Release': '<TAB>$(<LINK>) -o $@ $^ <MACH> -shared $(<PROJ>_LDFLAGS) -L$(NACL_SDK_ROOT)/lib/$(OSNAME)_<ARCH>_<tc>/<config> <LIBLIST>', } PEXE_TRANSLATE_RULE = """ @@ -93,8 +93,8 @@ PEXE_TRANSLATE_RULE = """ <TAB>$(TRANSLATE) -arch arm $< -o $@""" PEXE_LINK_RULES = { - 'Debug': '<TAB>$(<LINK>) -o $@ $^ -g $(<PROJ>_LDFLAGS) $(<TC>_LDFLAGS) <LIBLIST>\n' + PEXE_TRANSLATE_RULE, - 'Release': '<TAB>$(<LINK>) -o $@ $^ $(<PROJ>_LDFLAGS) $(<TC>_LDFLAGS) <LIBLIST>\n' + PEXE_TRANSLATE_RULE, + 'Debug': '<TAB>$(<LINK>) -o $@ $^ -g $(<TC>_LDFLAGS) $(<PROJ>_LDFLAGS) -L$(NACL_SDK_ROOT)/lib/$(OSNAME)_<ARCH>_<tc>/<config> <LIBLIST>\n' + PEXE_TRANSLATE_RULE, + 'Release': '<TAB>$(<LINK>) -o $@ $^ $(<TC>_LDFLAGS) $(<PROJ>_LDFLAGS) -L$(NACL_SDK_ROOT)/lib/$(OSNAME)_<ARCH>_<tc>/<config> <LIBLIST>\n' + PEXE_TRANSLATE_RULE, } WIN_LINK_RULES = { diff --git a/native_client_sdk/src/libraries/gtest/library.dsc b/native_client_sdk/src/libraries/gtest/library.dsc index a7405a8..ee5e87c 100644 --- a/native_client_sdk/src/libraries/gtest/library.dsc +++ b/native_client_sdk/src/libraries/gtest/library.dsc @@ -1,6 +1,7 @@ { 'TOOLS': ['newlib', 'glibc', 'pnacl', 'win'], 'SEARCH': [ + '.', '../../../../testing/gtest/include/gtest', '../../../../testing/gtest/include/gtest/internal', '../../../../testing/gtest/src', @@ -18,6 +19,7 @@ 'gtest-printers.cc', 'gtest-test-part.cc', 'gtest-typed-test.cc', + 'nacl_gtest_dummy_sys.cc', ], # Ignore warning: # gtest.cc:2555: error: enumeration value ‘COLOR_DEFAULT’ not handled in switch diff --git a/native_client_sdk/src/libraries/gtest/nacl_gtest_dummy_sys.cc b/native_client_sdk/src/libraries/gtest/nacl_gtest_dummy_sys.cc new file mode 100644 index 0000000..ef7cf61 --- /dev/null +++ b/native_client_sdk/src/libraries/gtest/nacl_gtest_dummy_sys.cc @@ -0,0 +1,36 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#if defined(__native_client__) +#include <errno.h> +#include <string.h> +#include <sys/types.h> +#endif + +extern "C" { + +#if defined(__native_client__) + +char* getcwd(char* buf, size_t size) { + if (size < 2) { + errno = ERANGE; + return NULL; + } + + return strncpy(buf, ".", size); +} + +int unlink(const char* pathname) { + errno = ENOSYS; + return -1; +} + +int mkdir(const char* pathname, mode_t mode) { + errno = ENOSYS; + return -1; +} + +#endif + +} // extern "C" diff --git a/native_client_sdk/src/libraries/nacl_mounts/kernel_handle.h b/native_client_sdk/src/libraries/nacl_mounts/kernel_handle.h index 141a788..4c11606 100644 --- a/native_client_sdk/src/libraries/nacl_mounts/kernel_handle.h +++ b/native_client_sdk/src/libraries/nacl_mounts/kernel_handle.h @@ -31,7 +31,7 @@ class KernelHandle : public RefObject { friend class KernelObject; friend class KernelProxy; void Acquire() { RefObject::Acquire(); } - void Release() { RefObject::Release(); } + bool Release() { return RefObject::Release(); } DISALLOW_COPY_AND_ASSIGN(KernelHandle); }; diff --git a/native_client_sdk/src/libraries/nacl_mounts/mount.h b/native_client_sdk/src/libraries/nacl_mounts/mount.h index cbb8014..53d160a 100644 --- a/native_client_sdk/src/libraries/nacl_mounts/mount.h +++ b/native_client_sdk/src/libraries/nacl_mounts/mount.h @@ -71,7 +71,7 @@ class Mount : public RefObject { friend class KernelObject; friend class KernelProxy; void Acquire() { RefObject::Acquire(); } - void Release() { RefObject::Release(); } + bool Release() { return RefObject::Release(); } template <class M, class P> friend class MountFactory; DISALLOW_COPY_AND_ASSIGN(Mount); @@ -79,10 +79,7 @@ class Mount : public RefObject { template<class C, class P> class MountFactory : public P { - protected: - MountFactory() - : P() {} - + public: static Mount* Create(int dev, StringMap_t& args) { Mount* mnt = new C(); if (mnt->Init(dev, args) == false) { @@ -92,7 +89,8 @@ template<class C, class P> class MountFactory : public P { return mnt; } - friend class KernelProxy; + protected: + MountFactory(): P() {} }; #endif // LIBRARIES_NACL_MOUNTS_MOUNT_H_ diff --git a/native_client_sdk/src/libraries/nacl_mounts_test/example.dsc b/native_client_sdk/src/libraries/nacl_mounts_test/example.dsc new file mode 100644 index 0000000..7db3e8d --- /dev/null +++ b/native_client_sdk/src/libraries/nacl_mounts_test/example.dsc @@ -0,0 +1,22 @@ +{ + 'TOOLS': ['newlib', 'glibc', 'pnacl', 'win'], + 'TARGETS': [ + { + 'NAME' : 'nacl_mounts_test', + 'TYPE' : 'main', + 'SOURCES' : [ + 'kernel_intercept_test.cc', + 'kernel_object_test.cc', + 'kernel_proxy_test.cc', + 'mount_node_test.cc', + 'mount_test.cc', + 'path_test.cc', + 'test.cc', + ], + 'LIBS': ['ppapi', 'pthread', 'gtest', 'nacl_mounts'] + } + ], + 'DEST': 'testing', + 'NAME': 'nacl_mounts_test', + 'EXPERIMENTAL': True, +} diff --git a/native_client_sdk/src/libraries/nacl_mounts_test/kernel_intercept_test.cc b/native_client_sdk/src/libraries/nacl_mounts_test/kernel_intercept_test.cc index dc0c0fc..494db2f 100644 --- a/native_client_sdk/src/libraries/nacl_mounts_test/kernel_intercept_test.cc +++ b/native_client_sdk/src/libraries/nacl_mounts_test/kernel_intercept_test.cc @@ -5,7 +5,6 @@ #include <fcntl.h> #include <pthread.h> -#include <unistd.h> #include <map> #include <string> @@ -14,7 +13,6 @@ #include "nacl_mounts/kernel_proxy.h" #include "nacl_mounts/path.h" -#define __STDC__ 1 #include "gtest/gtest.h" class KernelProxyMock : public KernelProxy { @@ -127,10 +125,12 @@ TEST(KernelIntercept, SanityChecks) { ki_chdir("foo"); EXPECT_EQ("chdir", mock->LastStr()); - ki_getcwd("foo", 1); + char getcwd_buffer[] = "foo"; + ki_getcwd(getcwd_buffer, 1); EXPECT_EQ("getcwd", mock->LastStr()); - ki_getwd("foo"); + char getwd_buffer[] = "foo"; + ki_getwd(getwd_buffer); EXPECT_EQ("getwd", mock->LastStr()); ki_dup(1); diff --git a/native_client_sdk/src/libraries/nacl_mounts_test/kernel_object_test.cc b/native_client_sdk/src/libraries/nacl_mounts_test/kernel_object_test.cc index 0c0519e..5854921 100644 --- a/native_client_sdk/src/libraries/nacl_mounts_test/kernel_object_test.cc +++ b/native_client_sdk/src/libraries/nacl_mounts_test/kernel_object_test.cc @@ -7,7 +7,6 @@ #include <fcntl.h> #include <pthread.h> #include <sys/stat.h> -#include <unistd.h> #include <map> #include <string> @@ -17,7 +16,6 @@ #include "nacl_mounts/mount.h" #include "nacl_mounts/path.h" -#define __STDC__ 1 #include "gtest/gtest.h" int g_MountCnt = 0; diff --git a/native_client_sdk/src/libraries/nacl_mounts_test/kernel_proxy_test.cc b/native_client_sdk/src/libraries/nacl_mounts_test/kernel_proxy_test.cc index 67a207d..e048e12 100644 --- a/native_client_sdk/src/libraries/nacl_mounts_test/kernel_proxy_test.cc +++ b/native_client_sdk/src/libraries/nacl_mounts_test/kernel_proxy_test.cc @@ -6,9 +6,7 @@ #include <errno.h> #include <fcntl.h> #include <pthread.h> -#include <sys/mount.h> #include <sys/stat.h> -#include <unistd.h> #include <map> #include <string> @@ -20,7 +18,6 @@ #include "nacl_mounts/mount_mem.h" #include "nacl_mounts/path.h" -#define __STDC__ 1 #include "gtest/gtest.h" @@ -30,37 +27,37 @@ TEST(KernelProxy, WorkingDirectory) { ki_init(new KernelProxy()); text[0] = 0; - getcwd(text, sizeof(text)); + ki_getcwd(text, sizeof(text)); EXPECT_STREQ("/", text); - char* alloc = getwd(NULL); + char* alloc = ki_getwd(NULL); EXPECT_EQ((char *) NULL, alloc); EXPECT_EQ(EFAULT, errno); text[0] = 0; - alloc = getwd(text); + alloc = ki_getwd(text); EXPECT_STREQ("/", alloc); - EXPECT_EQ(-1, chdir("/foo")); + EXPECT_EQ(-1, ki_chdir("/foo")); EXPECT_EQ(EEXIST, errno); - EXPECT_EQ(0, chdir("/")); + EXPECT_EQ(0, ki_chdir("/")); - EXPECT_EQ(0, mkdir("/foo", S_IREAD | S_IWRITE)); - EXPECT_EQ(-1, mkdir("/foo", S_IREAD | S_IWRITE)); + EXPECT_EQ(0, ki_mkdir("/foo", S_IREAD | S_IWRITE)); + EXPECT_EQ(-1, ki_mkdir("/foo", S_IREAD | S_IWRITE)); EXPECT_EQ(EEXIST, errno); memset(text, 0, sizeof(text)); - EXPECT_EQ(0, chdir("foo")); - EXPECT_EQ(text, getcwd(text, sizeof(text))); + EXPECT_EQ(0, ki_chdir("foo")); + EXPECT_EQ(text, ki_getcwd(text, sizeof(text))); EXPECT_STREQ("/foo", text); memset(text, 0, sizeof(text)); - EXPECT_EQ(-1, chdir("foo")); + EXPECT_EQ(-1, ki_chdir("foo")); EXPECT_EQ(EEXIST, errno); - EXPECT_EQ(0, chdir("..")); - EXPECT_EQ(0, chdir("/foo")); - EXPECT_EQ(text, getcwd(text, sizeof(text))); + EXPECT_EQ(0, ki_chdir("..")); + EXPECT_EQ(0, ki_chdir("/foo")); + EXPECT_EQ(text, ki_getcwd(text, sizeof(text))); EXPECT_STREQ("/foo", text); } @@ -72,52 +69,52 @@ TEST(KernelProxy, MemMountIO) { ki_init(new KernelProxy()); // Create "/foo" - EXPECT_EQ(0, mkdir("/foo", S_IREAD | S_IWRITE)); + EXPECT_EQ(0, ki_mkdir("/foo", S_IREAD | S_IWRITE)); // Fail to open "/foo/bar" - EXPECT_EQ(-1, open("/foo/bar", O_RDONLY)); + EXPECT_EQ(-1, ki_open("/foo/bar", O_RDONLY)); EXPECT_EQ(ENOENT, errno); // Create bar "/foo/bar" - fd1 = open("/foo/bar", O_RDONLY | O_CREAT); + fd1 = ki_open("/foo/bar", O_RDONLY | O_CREAT); EXPECT_NE(-1, fd1); // Open (optionally create) bar "/foo/bar" - fd2 = open("/foo/bar", O_RDONLY | O_CREAT); + fd2 = ki_open("/foo/bar", O_RDONLY | O_CREAT); EXPECT_NE(-1, fd2); // Fail to exclusively create bar "/foo/bar" - EXPECT_EQ(-1, open("/foo/bar", O_RDONLY | O_CREAT | O_EXCL)); + EXPECT_EQ(-1, ki_open("/foo/bar", O_RDONLY | O_CREAT | O_EXCL)); EXPECT_EQ(EEXIST, errno); // Write hello and world to same node with different descriptors // so that we overwrite each other - EXPECT_EQ(5, write(fd2, "WORLD", 5)); - EXPECT_EQ(5, write(fd1, "HELLO", 5)); + EXPECT_EQ(5, ki_write(fd2, "WORLD", 5)); + EXPECT_EQ(5, ki_write(fd1, "HELLO", 5)); - fd3 = open("/foo/bar", O_WRONLY); + fd3 = ki_open("/foo/bar", O_WRONLY); EXPECT_NE(-1, fd3); - len = read(fd3, text, sizeof(text)); + len = ki_read(fd3, text, sizeof(text)); if (len > -0) text[len] = 0; EXPECT_EQ(5, len); EXPECT_STREQ("HELLO", text); - EXPECT_EQ(0, close(fd1)); - EXPECT_EQ(0, close(fd2)); + EXPECT_EQ(0, ki_close(fd1)); + EXPECT_EQ(0, ki_close(fd2)); - fd1 = open("/foo/bar", O_WRONLY | O_APPEND); + fd1 = ki_open("/foo/bar", O_WRONLY | O_APPEND); EXPECT_NE(-1, fd1); - EXPECT_EQ(5, write(fd1, "WORLD", 5)); + EXPECT_EQ(5, ki_write(fd1, "WORLD", 5)); - len = read(fd3, text, sizeof(text)); + len = ki_read(fd3, text, sizeof(text)); if (len >= 0) text[len] = 0; EXPECT_EQ(5, len); EXPECT_STREQ("WORLD", text); - fd2 = open("/foo/bar", O_RDONLY); + fd2 = ki_open("/foo/bar", O_RDONLY); EXPECT_NE(-1, fd2); - len = read(fd2, text, sizeof(text)); + len = ki_read(fd2, text, sizeof(text)); if (len > 0) text[len] = 0; EXPECT_EQ(10, len); EXPECT_STREQ("HELLOWORLD", text); @@ -144,13 +141,13 @@ class KernelProxyMountMock : public KernelProxy { TEST(KernelProxy, MountInit) { ki_init(new KernelProxyMountMock()); - int res1 = mount("/", "/mnt1", "initfs", 0, "false,foo=bar"); + int res1 = ki_mount("/", "/mnt1", "initfs", 0, "false,foo=bar"); EXPECT_EQ("bar", g_StringMap["foo"]); EXPECT_EQ(-1, res1); EXPECT_EQ(EINVAL, errno); - int res2 = mount("/", "/mnt2", "initfs", 0, "true,bar=foo,x=y"); + int res2 = ki_mount("/", "/mnt2", "initfs", 0, "true,bar=foo,x=y"); EXPECT_NE(-1, res2); EXPECT_EQ("y", g_StringMap["x"]); -}
\ No newline at end of file +} diff --git a/native_client_sdk/src/libraries/nacl_mounts_test/mount_node_test.cc b/native_client_sdk/src/libraries/nacl_mounts_test/mount_node_test.cc index e38b1fe..3994b9d 100644 --- a/native_client_sdk/src/libraries/nacl_mounts_test/mount_node_test.cc +++ b/native_client_sdk/src/libraries/nacl_mounts_test/mount_node_test.cc @@ -5,14 +5,13 @@ #include <errno.h> #include <fcntl.h> -#include <unistd.h> #include "nacl_mounts/kernel_proxy.h" #include "nacl_mounts/mount_node.h" #include "nacl_mounts/mount_node_dir.h" #include "nacl_mounts/mount_node_mem.h" +#include "nacl_mounts/osdirent.h" -#define __STDC__ 1 #include "gtest/gtest.h" #define NULL_NODE ((MountNode *) NULL) @@ -79,7 +78,7 @@ TEST(MountNodeTest, File) { // Test properties EXPECT_EQ(0, file->GetLinks()); EXPECT_EQ(S_IREAD | S_IWRITE, file->GetMode()); - EXPECT_EQ(_S_IFREG, file->GetType()); + EXPECT_EQ(S_IFREG, file->GetType()); EXPECT_EQ(false, file->IsaDir()); EXPECT_EQ(true, file->IsaFile()); EXPECT_EQ(false, file->IsaTTY()); @@ -88,7 +87,7 @@ TEST(MountNodeTest, File) { // Test IO char buf1[1024]; char buf2[1024 * 2]; - for (int a=0; a < sizeof(buf1); a++) + for (size_t a = 0; a < sizeof(buf1); a++) buf1[a] = a; memset(buf2, 0, sizeof(buf2)); @@ -125,7 +124,7 @@ TEST(MountNodeTest, Directory) { // Test properties EXPECT_EQ(0, root->GetLinks()); EXPECT_EQ(S_IREAD | S_IWRITE, root->GetMode()); - EXPECT_EQ(_S_IFDIR, root->GetType()); + EXPECT_EQ(S_IFDIR, root->GetType()); EXPECT_EQ(true, root->IsaDir()); EXPECT_EQ(false, root->IsaFile()); EXPECT_EQ(false, root->IsaTTY()); diff --git a/native_client_sdk/src/libraries/nacl_mounts_test/mount_test.cc b/native_client_sdk/src/libraries/nacl_mounts_test/mount_test.cc index c5f2537..f649c2a 100644 --- a/native_client_sdk/src/libraries/nacl_mounts_test/mount_test.cc +++ b/native_client_sdk/src/libraries/nacl_mounts_test/mount_test.cc @@ -3,18 +3,16 @@ * found in the LICENSE file. */ -#include <dirent.h> #include <errno.h> #include <fcntl.h> -#include <unistd.h> #include <sys/stat.h> #include <string> #include "nacl_mounts/mount.h" #include "nacl_mounts/mount_mem.h" +#include "nacl_mounts/osdirent.h" -#define __STDC__ 1 #include "gtest/gtest.h" class MountMock : public MountMem { diff --git a/native_client_sdk/src/libraries/nacl_mounts_test/path_test.cc b/native_client_sdk/src/libraries/nacl_mounts_test/path_test.cc index 4e3caaa..44176f3 100644 --- a/native_client_sdk/src/libraries/nacl_mounts_test/path_test.cc +++ b/native_client_sdk/src/libraries/nacl_mounts_test/path_test.cc @@ -4,11 +4,9 @@ */ #include <fcntl.h> -#include <unistd.h> #include "nacl_mounts/kernel_proxy.h" #include "nacl_mounts/path.h" -#define __STDC__ 1 #include "gtest/gtest.h" TEST(PathTest, SanityChecks) { diff --git a/native_client_sdk/src/libraries/utils/ref_object.h b/native_client_sdk/src/libraries/utils/ref_object.h index cfee3a6..6cd8c84 100644 --- a/native_client_sdk/src/libraries/utils/ref_object.h +++ b/native_client_sdk/src/libraries/utils/ref_object.h @@ -21,10 +21,12 @@ class RefObject { void Acquire() { ref_count_++; } - void Release() { + bool Release() { if (--ref_count_ == 0) { delete this; + return false; } + return true; } protected: |