summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2017-06-06 07:29:06 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2017-06-06 07:29:06 +0000
commit21a25928bc7dab69a8efe9a2826c05f0591868e6 (patch)
tree9a32127b6b5ae61519a4247fdc7176d7e3d7de38
parenta9e7a641a7b470263cb1b3db92f4e11c30272ce8 (diff)
parent72349312959b0adf1217e73e35322f95c704164c (diff)
downloadextras-21a25928bc7dab69a8efe9a2826c05f0591868e6.tar.gz
release-request-2b9eb364-e73f-4091-8ad7-435c885e6bd0-for-git_oc-dr1-release-4070602 snap-temp-L36900000070867203
Change-Id: Ieacd91c6ee717808651d6c5364c9d308a614ddde
-rw-r--r--f2fs_utils/f2fs_dlutils.c4
-rw-r--r--f2fs_utils/f2fs_ioutils.c62
-rw-r--r--f2fs_utils/f2fs_utils.c13
-rw-r--r--simpleperf/scripts/app_profiler.py10
-rw-r--r--simpleperf/scripts/utils.py12
-rw-r--r--tests/kernel.config/Android.mk5
-rw-r--r--tests/kernel.config/nfs_test.cpp28
7 files changed, 101 insertions, 33 deletions
diff --git a/f2fs_utils/f2fs_dlutils.c b/f2fs_utils/f2fs_dlutils.c
index 2ba3f7cc..4b5e13ea 100644
--- a/f2fs_utils/f2fs_dlutils.c
+++ b/f2fs_utils/f2fs_dlutils.c
@@ -39,7 +39,6 @@
int (*f2fs_format_device_dl)(void);
void (*f2fs_init_configuration_dl)(void);
-struct f2fs_configuration *c_dl;
int f2fs_format_device(void) {
assert(f2fs_format_device_dl);
@@ -59,8 +58,7 @@ int dlopenf2fs() {
}
f2fs_format_device_dl = dlsym(f2fs_lib, "f2fs_format_device");
f2fs_init_configuration_dl = dlsym(f2fs_lib, "f2fs_init_configuration");
- c_dl = dlsym(f2fs_lib, "c");
- if (!f2fs_format_device_dl || !f2fs_init_configuration_dl || !c_dl) {
+ if (!f2fs_format_device_dl || !f2fs_init_configuration_dl) {
return -1;
}
return 0;
diff --git a/f2fs_utils/f2fs_ioutils.c b/f2fs_utils/f2fs_ioutils.c
index d3bc727d..c9275ff2 100644
--- a/f2fs_utils/f2fs_ioutils.c
+++ b/f2fs_utils/f2fs_ioutils.c
@@ -83,7 +83,7 @@ struct selabel_handle;
#endif
-extern struct f2fs_configuration *c_dl;
+struct f2fs_configuration c;
struct sparse_file *f2fs_sparse_file;
struct buf_item {
@@ -94,11 +94,29 @@ struct buf_item {
struct buf_item *buf_list;
+static int __get_device_fd(__u64 *offset)
+{
+ __u64 blk_addr = *offset >> F2FS_BLKSIZE_BITS;
+ int i;
+
+ for (i = 0; i < c.ndevs; i++) {
+ if (c.devices[i].start_blkaddr <= blk_addr &&
+ c.devices[i].end_blkaddr >= blk_addr) {
+ *offset -=
+ c.devices[i].start_blkaddr << F2FS_BLKSIZE_BITS;
+ return c.devices[i].fd;
+ }
+ }
+ return -1;
+}
+
static int dev_write_fd(void *buf, __u64 offset, size_t len)
{
- if (lseek64(c_dl->devices[0].fd, (off64_t)offset, SEEK_SET) < 0)
+ int fd = __get_device_fd(&offset);
+
+ if (lseek64(fd, (off64_t)offset, SEEK_SET) < 0)
return -1;
- ssize_t written = write(c_dl->devices[0].fd, buf, len);
+ ssize_t written = write(fd, buf, len);
if (written == -1)
return -1;
if ((size_t)written != len)
@@ -138,11 +156,11 @@ static int dev_write_sparse(void *buf, __u64 byte_offset, size_t byte_len)
return 0;
}
-void f2fs_finalize_device()
+void f2fs_finalize_device(void)
{
}
-int f2fs_trim_device()
+int f2fs_trim_devices(void)
{
return 0;
}
@@ -160,24 +178,39 @@ int dev_read(void *buf, __u64 offset, size_t len)
return 0;
}
+int dev_readahead(__u64 offset, size_t len)
+{
+ return 0;
+}
+
int dev_write(void *buf, __u64 offset, size_t len)
{
- if (c_dl->devices[0].fd >= 0) {
+ int fd = __get_device_fd(&offset);
+
+ if (fd >= 0) {
return dev_write_fd(buf, offset, len);
} else {
return dev_write_sparse(buf, offset, len);
}
}
-int dev_write_block(void *buf, __u64 offset)
+int dev_write_block(void *buf, __u64 blk_addr)
+{
+ assert(false); // Must not be invoked.
+ return 0;
+}
+
+int dev_write_dump(void *buf, __u64 offset, size_t len)
{
- return dev_write(buf, offset << F2FS_BLKSIZE_BITS, F2FS_BLKSIZE);
+ assert(false); // Must not be invoked.
+ return 0;
}
int dev_fill(void *buf, __u64 offset, size_t len)
{
+ int fd = __get_device_fd(&offset);
int ret;
- if (c_dl->devices[0].fd >= 0) {
+ if (fd >= 0) {
return dev_write_fd(buf, offset, len);
}
// sparse file fills with zero by default.
@@ -185,6 +218,12 @@ int dev_fill(void *buf, __u64 offset, size_t len)
return 0;
}
+int dev_fill_block(void *buf, __u64 blk_addr)
+{
+ assert(false); // Must not be invoked.
+ return 0;
+}
+
int dev_read_block(void *buf, __u64 blk_addr)
{
assert(false); // Must not be invoked.
@@ -197,3 +236,8 @@ int dev_read_blocks(void *buf, __u64 addr, __u32 nr_blks)
return 0;
}
+int dev_reada_block(__u64 blk_addr)
+{
+ assert(false); // Must not be invoked.
+ return 0;
+}
diff --git a/f2fs_utils/f2fs_utils.c b/f2fs_utils/f2fs_utils.c
index 52236801..0aa2f7a2 100644
--- a/f2fs_utils/f2fs_utils.c
+++ b/f2fs_utils/f2fs_utils.c
@@ -42,11 +42,12 @@ struct selabel_handle;
extern void flush_sparse_buffs();
-extern struct f2fs_configuration *c_dl;
+struct f2fs_configuration c;
struct sparse_file *f2fs_sparse_file;
extern int dlopenf2fs();
static void reset_f2fs_info() {
+ memset(&c, 0, sizeof(c));
if (f2fs_sparse_file) {
sparse_file_destroy(f2fs_sparse_file);
f2fs_sparse_file = NULL;
@@ -62,13 +63,9 @@ int make_f2fs_sparse_fd(int fd, long long len,
reset_f2fs_info();
f2fs_init_configuration();
len &= ~((__u64)(F2FS_BLKSIZE - 1));
- c_dl->ndevs = 1;
- c_dl->devices[0].total_sectors = len / c_dl->devices[0].sector_size;
- c_dl->sector_size = c_dl->devices[0].sector_size;
- c_dl->sectors_per_blk = F2FS_BLKSIZE / c_dl->sector_size;
- c_dl->total_sectors = c_dl->devices[0].total_sectors;
- c_dl->start_sector = 0;
- c_dl->trim = 0;
+ c.sector_size = DEFAULT_SECTOR_SIZE;
+ c.total_sectors = len / c.sector_size;
+ c.start_sector = 0;
f2fs_sparse_file = sparse_file_new(F2FS_BLKSIZE, len);
f2fs_format_device();
sparse_file_write(f2fs_sparse_file, fd, /*gzip*/0, /*sparse*/1, /*crc*/0);
diff --git a/simpleperf/scripts/app_profiler.py b/simpleperf/scripts/app_profiler.py
index ea181f16..25098d30 100644
--- a/simpleperf/scripts/app_profiler.py
+++ b/simpleperf/scripts/app_profiler.py
@@ -121,7 +121,7 @@ class AppProfiler(object):
self.adb.set_property('security.perf_harden', '0')
if self.is_root_device:
# We can enable kernel symbols
- self.adb.run(['shell', 'echo', '0', '>/proc/sys/kernel/kptr_restrict'])
+ self.adb.run(['shell', 'echo 0 >/proc/sys/kernel/kptr_restrict'])
def _recompile_app(self):
@@ -271,7 +271,7 @@ class AppProfiler(object):
def collect_profiling_data(self):
- self.run_in_app_dir(['cat', 'perf.data', '>' + self.config['perf_data_path']])
+ self.run_in_app_dir(['cat', 'perf.data'], self.config['perf_data_path'])
config = copy.copy(self.config)
config['symfs_dirs'] = []
if self.config['native_lib_dir']:
@@ -280,13 +280,13 @@ class AppProfiler(object):
binary_cache_builder.build_binary_cache()
- def run_in_app_dir(self, args):
+ def run_in_app_dir(self, args, stdout_file=None):
if self.is_root_device:
cmd = 'cd /data/data/' + self.config['app_package_name'] + ' && ' + (' '.join(args))
- return self.adb.check_run_and_return_output(['shell', cmd])
+ return self.adb.check_run_and_return_output(['shell', cmd], stdout_file)
else:
return self.adb.check_run_and_return_output(
- ['shell', 'run-as', self.config['app_package_name']] + args)
+ ['shell', 'run-as', self.config['app_package_name']] + args, stdout_file)
if __name__ == '__main__':
diff --git a/simpleperf/scripts/utils.py b/simpleperf/scripts/utils.py
index 5474676d..a0b3b3ba 100644
--- a/simpleperf/scripts/utils.py
+++ b/simpleperf/scripts/utils.py
@@ -104,13 +104,12 @@ class AdbHelper(object):
return self.run_and_return_output(adb_args)[0]
- def run_and_return_output(self, adb_args):
+ def run_and_return_output(self, adb_args, stdout_file=None):
adb_args = [self.adb_path] + adb_args
log_debug('run adb cmd: %s' % adb_args)
- if adb_args[-1][0] == '>':
- stdout_file = adb_args[-1][1:]
+ if stdout_file:
with open(stdout_file, 'wb') as stdout_fh:
- returncode = subprocess.call(adb_args[:-1], stdout=stdout_fh)
+ returncode = subprocess.call(adb_args, stdout=stdout_fh)
stdoutdata = ''
else:
subproc = subprocess.Popen(adb_args, stdout=subprocess.PIPE)
@@ -123,13 +122,12 @@ class AdbHelper(object):
log_debug('run adb cmd: %s [result %s]' % (adb_args, result))
return (result, stdoutdata)
-
def check_run(self, adb_args):
self.check_run_and_return_output(adb_args)
- def check_run_and_return_output(self, adb_args):
- result, stdoutdata = self.run_and_return_output(adb_args)
+ def check_run_and_return_output(self, adb_args, stdout_file=None):
+ result, stdoutdata = self.run_and_return_output(adb_args, stdout_file)
if not result:
log_fatal('run "adb %s" failed' % adb_args)
return stdoutdata
diff --git a/tests/kernel.config/Android.mk b/tests/kernel.config/Android.mk
index 9be5d9d0..0c87107f 100644
--- a/tests/kernel.config/Android.mk
+++ b/tests/kernel.config/Android.mk
@@ -15,10 +15,11 @@ test_c_flags := \
# Required Tests
cts_src_files := \
+ logger_test.cpp \
multicast_test.cpp \
+ nfs_test.cpp \
pstore_test.cpp \
sysvipc_test.cpp \
- logger_test.cpp
# Required plus Recommended Tests
# TODO: move aslr_test.cpp back to cts_src_files b/36888825
@@ -34,6 +35,7 @@ LOCAL_MODULE_TAGS := tests
LOCAL_CFLAGS := $(test_c_flags)
LOCAL_CFLAGS := -DHAS_KCMP
LOCAL_SRC_FILES := $(test_src_files)
+LOCAL_SHARED_LIBRARIES := libbase
include $(BUILD_NATIVE_TEST)
include $(CLEAR_VARS)
@@ -46,6 +48,7 @@ LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)/nativetest
LOCAL_MULTILIB := both
LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+LOCAL_SHARED_LIBRARIES := libbase
LOCAL_STATIC_LIBRARIES := libgtest libgtest_main
LOCAL_COMPATIBILITY_SUITE := cts
diff --git a/tests/kernel.config/nfs_test.cpp b/tests/kernel.config/nfs_test.cpp
new file mode 100644
index 00000000..01b45a74
--- /dev/null
+++ b/tests/kernel.config/nfs_test.cpp
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <string>
+
+#include <android-base/file.h>
+#include <gtest/gtest.h>
+
+TEST(kernel_config, NOT_CONFIG_NFS_) {
+ std::string fs;
+ EXPECT_TRUE(android::base::ReadFileToString("/proc/filesystems", &fs));
+ EXPECT_TRUE(fs.find("\tnfs\n") == std::string::npos);
+ EXPECT_TRUE(fs.find("\tnfs4\n") == std::string::npos);
+ EXPECT_TRUE(fs.find("\tnfsd\n") == std::string::npos);
+}