summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Baptiste Queru <jbq@google.com>2009-11-15 12:07:13 -0800
committerJean-Baptiste Queru <jbq@google.com>2009-11-15 12:07:14 -0800
commita015c9d506a756acd7aa9f8c67d5c9649fa2b7fc (patch)
treeeb9eab5519fe8c98c3d0779bfbc87934abe0fde7
parent71e762486b8154fc97fcb1b1c1659635a6312a12 (diff)
parent0ac334cf3b71724451641a44553252a44a43b1f8 (diff)
downloadextras-a015c9d506a756acd7aa9f8c67d5c9649fa2b7fc.tar.gz
merge from eclair
-rw-r--r--libpagemap/include/pagemap/pagemap.h2
-rw-r--r--libpagemap/pm_process.c7
-rw-r--r--tests/bionic/libc/Android.mk1
-rw-r--r--tests/bionic/libc/common/test_strftime_2039.c36
-rw-r--r--tests/framebuffer/Android.mk9
-rw-r--r--tests/framebuffer/fb_test.c16
-rw-r--r--tests/framebuffer/mdp_test.c324
-rw-r--r--tests/memtest/memtest.cpp7
-rw-r--r--tests/sdcard/README63
-rwxr-xr-xtests/sdcard/plot_sdcard.py5
10 files changed, 456 insertions, 14 deletions
diff --git a/libpagemap/include/pagemap/pagemap.h b/libpagemap/include/pagemap/pagemap.h
index 3ee8d729..09ff29d8 100644
--- a/libpagemap/include/pagemap/pagemap.h
+++ b/libpagemap/include/pagemap/pagemap.h
@@ -142,7 +142,7 @@ int pm_process_pagemap_range(pm_process_t *proc,
* Returns an array of pointers to pm_map_t through *maps.
* The array should be freed by the caller, but the maps should not be
* modified or destroyed. */
-int pm_process_maps(pm_process_t *proc, pm_map_t ***maps_out, int *len);
+int pm_process_maps(pm_process_t *proc, pm_map_t ***maps_out, size_t *len);
/* Destroy a pm_process_t. */
int pm_process_destroy(pm_process_t *proc);
diff --git a/libpagemap/pm_process.c b/libpagemap/pm_process.c
index cfed4746..1ab367d8 100644
--- a/libpagemap/pm_process.c
+++ b/libpagemap/pm_process.c
@@ -98,7 +98,6 @@ int pm_process_pagemap_range(pm_process_t *proc,
uint64_t *range;
off_t off;
int error;
- ssize_t len_read;
if (!proc || (low >= high) || !range_out || !len)
return -1;
@@ -116,8 +115,8 @@ int pm_process_pagemap_range(pm_process_t *proc,
free(range);
return error;
}
- len_read = read(proc->pagemap_fd, (char*)range, numpages * sizeof(uint64_t));
- if (len_read < (ssize_t)numpages * sizeof(uint64_t)) {
+ error = read(proc->pagemap_fd, (char*)range, numpages * sizeof(uint64_t));
+ if (error < numpages * sizeof(uint64_t)) {
error = (error < 0) ? errno : -1;
free(range);
return error;
@@ -129,7 +128,7 @@ int pm_process_pagemap_range(pm_process_t *proc,
return 0;
}
-int pm_process_maps(pm_process_t *proc, pm_map_t ***maps_out, int *len) {
+int pm_process_maps(pm_process_t *proc, pm_map_t ***maps_out, size_t *len) {
pm_map_t **maps;
if (!proc || !maps_out || !len)
diff --git a/tests/bionic/libc/Android.mk b/tests/bionic/libc/Android.mk
index 4e4bcc64..d08d30a6 100644
--- a/tests/bionic/libc/Android.mk
+++ b/tests/bionic/libc/Android.mk
@@ -71,6 +71,7 @@ sources := \
common/test_semaphore.c \
common/test_seteuid.c \
common/test_static_cpp_mutex.cpp \
+ common/test_strftime_2039.c \
common/test_tm_zone.c \
common/test_udp.c \
diff --git a/tests/bionic/libc/common/test_strftime_2039.c b/tests/bionic/libc/common/test_strftime_2039.c
new file mode 100644
index 00000000..25ed5405
--- /dev/null
+++ b/tests/bionic/libc/common/test_strftime_2039.c
@@ -0,0 +1,36 @@
+/* this tests tries to call strftime() with a date > 2038
+ * to see if it works correctly.
+ */
+#include <time.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+int main(void)
+{
+ char buff[256];
+ time_t now = time(NULL);
+ struct tm tm = *localtime(&now);
+
+ tm.tm_year = 2039 - 1900;
+
+ /* "%s" is the number of seconds since the epoch */
+ if (strftime(buff, sizeof buff, "%s", &tm) == 0) {
+ fprintf(stderr, "strftime() returned 0\n");
+ exit(EXIT_FAILURE);
+ }
+ printf("seconds since epoch: %s\n", buff);
+
+ /* a 32-bit limited implementation will return a negative number */
+ if (buff[0] == '-') {
+ fprintf(stderr, "FAIL\n");
+ exit(EXIT_FAILURE);
+ }
+
+ /* "%c" is the usual date string for the current locale */
+ if (strftime(buff, sizeof buff, "%c", &tm) == 0) {
+ fprintf(stderr, "strftime() returned 0\n");
+ exit(EXIT_FAILURE);
+ }
+ printf("date string : %s\n", buff);
+ return 0;
+}
diff --git a/tests/framebuffer/Android.mk b/tests/framebuffer/Android.mk
index 4f789b9e..2c048573 100644
--- a/tests/framebuffer/Android.mk
+++ b/tests/framebuffer/Android.mk
@@ -30,4 +30,13 @@ LOCAL_MODULE_TAGS := optional
LOCAL_FORCE_STATIC_EXECUTABLE := true
LOCAL_STATIC_LIBRARIES := libc
include $(BUILD_EXECUTABLE)
+
+include $(CLEAR_VARS)
+LOCAL_SRC_FILES := mdp_test.c
+LOCAL_MODULE = test-mdp
+LOCAL_MODULE_TAGS := optional
+LOCAL_FORCE_STATIC_EXECUTABLE := true
+LOCAL_STATIC_LIBRARIES := libc
+include $(BUILD_EXECUTABLE)
+
endif # sim
diff --git a/tests/framebuffer/fb_test.c b/tests/framebuffer/fb_test.c
index 3bd7e8e5..39435063 100644
--- a/tests/framebuffer/fb_test.c
+++ b/tests/framebuffer/fb_test.c
@@ -111,7 +111,8 @@ static void set_active_framebuffer(unsigned n)
vi.yoffset = n * vi.yres;
if(ioctl(gr_fb_fd, FBIOPUT_VSCREENINFO, &vi) < 0) {
fprintf(stderr,"active fb swap failed!\n");
- }
+ } else
+ printf("active buffer: %d\n", n);
}
static void dumpinfo(struct fb_fix_screeninfo *fi, struct fb_var_screeninfo *vi)
@@ -218,24 +219,27 @@ void clear_screen(int w, int h, uint16_t* loc)
loc[i + j*(stride)] = 0x0000;
}
-
int main(int argc, char **argv) {
int w;
int h;
+ int id = 0;
gr_init();
w = vi.xres;
h = vi.yres;
clear_screen(w, h, (uint16_t *)gr_framebuffer[0].data);
+ clear_screen(w, h, (uint16_t *)gr_framebuffer[1].data);
if (argc > 2) {
w = atoi(argv[1]);
h = atoi(argv[2]);
}
- draw_grid(w, h, (uint16_t *)gr_framebuffer[0].data);
- printf("%lld\n", (tv2.tv_sec*1000000000LL + tv2.tv_nsec) - (tv.tv_sec*1000000000LL + tv.tv_nsec));
- set_active_framebuffer(1);
- set_active_framebuffer(0);
+ if (argc > 3)
+ id = !!atoi(argv[3]);
+
+ draw_grid(w, h, (uint16_t *)gr_framebuffer[id].data);
+ set_active_framebuffer(!id);
+ set_active_framebuffer(id);
return 0;
}
diff --git a/tests/framebuffer/mdp_test.c b/tests/framebuffer/mdp_test.c
new file mode 100644
index 00000000..506852fa
--- /dev/null
+++ b/tests/framebuffer/mdp_test.c
@@ -0,0 +1,324 @@
+/*
+ * Copyright (C) 2007 Google Inc.
+ *
+ * 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 <stdlib.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+
+#include <linux/fb.h>
+#include <linux/msm_mdp.h>
+
+static struct fb_var_screeninfo vi;
+
+static int open_file(char *name, int *fd, int *len, int *fmt)
+{
+ struct stat stat;
+ char *type, *fn;
+
+ type = name;
+ fn = strchr(name, ':');
+ if (!fn)
+ return -1;
+ *(fn++) = '\0';
+
+ if (!strncmp(type, "yuv420", 6))
+ *fmt = MDP_Y_CBCR_H2V2;
+ else if (!strncmp(type, "rgb565", 6))
+ *fmt = MDP_RGB_565;
+ else {
+ fprintf(stderr, "Unsupported image type: %s\n", type);
+ return -1;
+ }
+
+ *fd = open(fn, O_RDONLY);
+ if (*fd < 0) {
+ perror("cannot open file");
+ return -1;
+ }
+
+ if (fstat(*fd, &stat) < 0) {
+ perror("cannot fstat file");
+ goto err;
+ }
+
+ *len = stat.st_size;
+
+ printf("Successfully opened file %s (fmt=%d len=%d fd=%d)\n", fn, *fmt,
+ *len, *fd);
+ return 0;
+
+err:
+ close(*fd);
+ return -1;
+}
+
+static int get_pmem(int *fd, void **data, int sz)
+{
+ *fd = open("/dev/pmem", O_RDWR | O_NONBLOCK | O_SYNC);
+ if (*fd < 0) {
+ perror("cannot open /dev/pmem");
+ return -1;
+ }
+
+ sz = (sz + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1);
+ *data = mmap(NULL, sz, PROT_READ | PROT_WRITE, MAP_SHARED, *fd, 0);
+ if (*data == MAP_FAILED) {
+ perror("pmem mmap");
+ goto err_pmem_mmap;
+ }
+
+ return 0;
+
+err_pmem_mmap:
+ close(*fd);
+ return -1;
+}
+
+static int get_framebuffer(int *fd, char **fb, int *width, int *height)
+{
+ struct fb_fix_screeninfo fi;
+ void *bits;
+
+ *fd = open("/dev/graphics/fb0", O_RDWR);
+ if(*fd < 0) {
+ perror("cannot open fb0");
+ return -1;
+ }
+
+ if(ioctl(*fd, FBIOGET_FSCREENINFO, &fi) < 0) {
+ perror("failed to get fb0 info");
+ return -1;
+ }
+
+ if(ioctl(*fd, FBIOGET_VSCREENINFO, &vi) < 0) {
+ perror("failed to get fb0 info");
+ return -1;
+ }
+
+ bits = mmap(0, fi.smem_len, PROT_READ | PROT_WRITE, MAP_SHARED, *fd, 0);
+ if(bits == MAP_FAILED) {
+ perror("failed to mmap framebuffer");
+ return -1;
+ }
+
+ *width = vi.xres;
+ *height = vi.yres;
+ *fb = bits;
+ return 0;
+}
+
+static void set_active_framebuffer(int fd, unsigned n)
+{
+
+ if(n > 1) return;
+ vi.yres_virtual = vi.yres * 2;
+ vi.yoffset = n * vi.yres;
+ if(ioctl(fd, FBIOPUT_VSCREENINFO, &vi) < 0) {
+ fprintf(stderr,"active fb swap failed!\n");
+ }
+}
+
+/* geometry: WxH+X+Y */
+int parse_geometry(char *geom, int *w, int *h, int *x, int *y)
+{
+ char *ptr;
+
+ *w = *h = 0;
+
+ if (!(ptr = strchr(geom, 'x')))
+ return -1;
+ *ptr = '\0';
+ *w = atoi(geom);
+ geom = ptr + 1;
+
+ ptr = strchr(geom, '+');
+ if (ptr)
+ *ptr = '\0';
+ *h = atoi(geom);
+ if (!ptr)
+ return 0;
+
+ geom = ptr + 1;
+
+ if (!x || !y || !(ptr = strchr(geom, '+')))
+ return -1;
+ *ptr = '\0';
+ *x = atoi(geom);
+ geom = ptr + 1;
+
+ *y = atoi(geom);
+
+ return 0;
+}
+
+int main(int argc, const char *argv[])
+{
+ int fb_fd, width, height;
+ char* fb;
+ struct mdp_blit_req_list *req_list;
+ struct mdp_blit_req *req;
+ int opt;
+ int srcw = 0, srch = 0, dstw = 0, dsth = 0;
+ int srcx = 0; int srcy = 0;
+ int dstx = 10; int dsty = 10;
+ int src_imgw = 0, src_imgh = 0, dst_imgw = 0, dst_imgh = 0;
+ int from;
+ int src_fmt;
+ int dst_fmt = MDP_RGB_565;
+ int src_fd = -1;
+ void *src_data;
+
+ req_list = malloc(sizeof(struct mdp_blit_req_list) +
+ sizeof(struct mdp_blit_req));
+ req_list->count = 1;
+ req = req_list->req;
+
+
+ while ((opt = getopt(argc, argv, "s:d:f:t:u:v:")) != -1) {
+ switch (opt) {
+ case 's':
+ if (parse_geometry(optarg, &srcw, &srch, &srcx, &srcy)) {
+ fprintf(stderr, "Can't parse source\n");
+ exit(-1);
+ }
+ printf("Got source: w=%d h=%d x=%d y=%d\n", srcw, srch, srcx, srcy);
+ break;
+
+ case 'd':
+ if (parse_geometry(optarg, &dstw, &dsth, &dstx, &dsty)) {
+ fprintf(stderr, "Can't parse dest\n");
+ exit(-1);
+ }
+ printf("Got dest: w=%d h=%d x=%d y=%d\n", dstw, dsth, dstx, dsty);
+ break;
+
+ case 'u':
+ if (parse_geometry(optarg, &src_imgw, &src_imgh, NULL, NULL)) {
+ fprintf(stderr, "Can't parse src image size\n");
+ exit(-1);
+ }
+ printf("Got src img sz: w=%d h=%d\n", src_imgw, src_imgh);
+ break;
+
+ case 'v':
+ if (parse_geometry(optarg, &dst_imgw, &dst_imgh, NULL, NULL)) {
+ fprintf(stderr, "Can't parse dst image size\n");
+ exit(-1);
+ }
+ printf("Got dst img sz: w=%d h=%d\n", dst_imgw, dst_imgh);
+ break;
+
+ case 'f':
+ {
+ int file_fd;
+ int file_len;
+ int bytes;
+ void *ptr;
+ if (open_file(optarg, &file_fd, &file_len, &src_fmt) < 0) {
+ fprintf(stderr, "Can't open source file\n");
+ exit(-1);
+ }
+
+ if (get_pmem(&src_fd, &src_data, file_len) < 0) {
+ close(file_fd);
+ exit(-1);
+ }
+
+ ptr = src_data;
+ while (file_len) {
+ bytes = read(file_fd, ptr, file_len);
+ if (bytes < 0) {
+ perror("Could not read data from file");
+ exit(-1);
+ }
+ file_len -= bytes;
+ ptr += bytes;
+ }
+ }
+ break;
+
+ case 't':
+ if (!strncmp(optarg, "yuv420", 6))
+ dst_fmt = MDP_Y_CBCR_H2V2;
+#if 0
+ else if (!strncmp(optarg, "rgb565", 6))
+ dst_fmt = MDP_RGB_565;
+#endif
+ break;
+
+ default:
+ fprintf(stderr, "Usage: %s -s source -d dest\n", argv[0]);
+ exit(-1);
+ }
+ }
+
+ if (get_framebuffer(&fb_fd, &fb, &width, &height)) {
+ printf("couldnt' get fb\n");
+ return -1;
+ }
+
+ set_active_framebuffer(fb_fd, 0);
+
+ if (!src_imgw || !src_imgh) {
+ src_imgw = width;
+ src_imgh = height;
+ }
+
+ if (!dst_imgw || !dst_imgh) {
+ dst_imgw = width;
+ dst_imgh = height;
+ }
+
+ if (src_fd < 0) {
+ src_fd = fb_fd;
+ src_fmt = MDP_RGB_565;
+ }
+
+ req->src.width = src_imgw;
+ req->src.height = src_imgh;
+ req->src.format = src_fmt;
+ req->src.offset = 0;
+ req->src.memory_id = src_fd;
+ req->src_rect.x = srcx;
+ req->src_rect.y = srcy;
+ req->src_rect.w = srcw;
+ req->src_rect.h = srch;
+
+ req->dst.width = dst_imgw;
+ req->dst.height = dst_imgh;
+ req->dst.format = dst_fmt;
+ req->dst.offset = 0;
+ req->dst.memory_id = fb_fd;
+ req->dst_rect.x = dstx;
+ req->dst_rect.y = dsty;
+ req->dst_rect.w = dstw;
+ req->dst_rect.h = dsth;
+ req->alpha = MDP_ALPHA_NOP;
+ req->transp_mask = MDP_TRANSP_NOP;
+// req->flags = MDP_ROT_90;
+ req->flags = MDP_ROT_NOP;
+
+ if(ioctl(fb_fd, MSMFB_BLIT, req_list))
+ fprintf(stderr, "crap, failed blit\n");
+
+ printf("Done\n");
+ return 0;
+}
diff --git a/tests/memtest/memtest.cpp b/tests/memtest/memtest.cpp
index d6cc9b21..610421e6 100644
--- a/tests/memtest/memtest.cpp
+++ b/tests/memtest/memtest.cpp
@@ -36,6 +36,9 @@ const int CPU_FREQ_EST = 384;
const int BRANCH_CYCLE = 2;
#endif
+//extern "C" void* xmemcpy(void*, void*, size_t);
+#define MEMCPY memcpy
+
typedef long long nsecs_t;
static nsecs_t system_time()
@@ -188,7 +191,7 @@ int memcpy_test(int argc, char** argv)
nsecs_t t = -system_time();
register int count = REPEAT;
do {
- memcpy(ddd, sss+offset, size);
+ MEMCPY(ddd, sss+offset, size);
} while (--count);
t += system_time() - overhead;
const float throughput = (size*1000000000.0f*REPEAT) / (1024*1024*t);
@@ -234,7 +237,7 @@ int validate_memcpy(char* s, char* d, size_t size)
{
int nberr = 0;
memset(d-4, 0x55, size+8);
- memcpy(s, d, size);
+ MEMCPY(s, d, size);
if (memcmp(s,d,size)) {
printf("*** memcpy(%p,%p,%lu) destination != source\n",s,d,size);
nberr++;
diff --git a/tests/sdcard/README b/tests/sdcard/README
new file mode 100644
index 00000000..210bb43f
--- /dev/null
+++ b/tests/sdcard/README
@@ -0,0 +1,63 @@
+This directory contains tools to profile the sdcard performance.
+
+There are 2 parts to the tool:
+* A binary that runs on the device, exercises the sdcard and send
+ measurment data back to the host (sdcard_perf_test).
+* A host python script to plot the data.
+
+Additionally, there is script 'profile_sdcard.sh' that allows you
+to check how the sdcard scale with the number of processes.
+
+INSTALLATION
+============
+Build, install and mount debugfs. In this directory with a properly
+configured enviroment:
+
+ mm SDCARD_TESTS=1
+ adb remount
+ adb push $ANDROID_PRODUCT_OUT/system/bin/sdcard_perf_test /system/bin/sdcard_perf_test
+ adb shell mount -t debugfs none /sys/kernel/debug
+
+If you want to graph the results you need gnuplot and numpy:
+
+ sudo apt-get install gnuplot python-numpy python-numeric
+
+You need Gnuplot.py version 1.8 (not the one coming with ubuntu).
+Download it from the Gnuplot.py web site. Extract to a temp
+directory, chdir and run:
+
+ sudo python setup.py install
+
+
+INVOCATION
+==========
+
+Run a simple test:
+
+ adb shell sdcard_perf_test --test=write --size=1000 --chunk-size=100 --procnb=1 --iterations=100
+
+This test will write 1000kbyte (1M) files using writes of 100kbytes (so 10 writes per file) using
+only 1 process for 100 times (100 files will be written on the sdcard).
+The test will not call sync to flush the writes.
+At the end of the test, some stats for the 'open' and 'write' system calls are written.
+
+If you want to plot the data, you need to use the --dump option and provide a file:
+
+ adb shell sdcard_perf_test --test=write --size=1000 --chunk-size=100 --procnb=1 --iterations=100 --dump >/tmp/data.txt
+
+PLOTTING
+========
+
+To plot the result using the iter number of the x axis:
+
+ plot_sdcard.py -i /tmp/data.txt
+
+To plot the result using time for the x axis:
+
+ plot_sdcard.py -t /tmp/data.txt
+
+To plot the result from the profiler:
+
+ profile_sdcard.sh
+ plot_sdcard.py -p
+
diff --git a/tests/sdcard/plot_sdcard.py b/tests/sdcard/plot_sdcard.py
index 19b83c3c..0959465c 100755
--- a/tests/sdcard/plot_sdcard.py
+++ b/tests/sdcard/plot_sdcard.py
@@ -96,7 +96,7 @@ class Metadata(object):
def Parse(self, line):
if line.startswith('# Kernel:'):
- self.kernel = re.search('Linux version ([0-9.]+-[0-9]+)', line).group(1)
+ self.kernel = re.search('Linux version ([0-9.]+-[^ ]+)', line).group(1)
elif line.startswith('# Command:'):
self.command_line = re.search('# Command: [/\w_]+ (.*)', line).group(1)
self.command_line = self.command_line.replace(' --', '-')
@@ -328,4 +328,7 @@ def main(argv):
if __name__ == '__main__':
+ if Gnuplot.__version__ != "1.8":
+ print "Gnuplot should be 1.8. See REAME file"
+ sys.exit(2)
main(sys.argv)