diff options
-rw-r--r-- | ext4_utils/Android.mk | 4 | ||||
-rw-r--r-- | ext4_utils/contents.c | 5 | ||||
-rw-r--r-- | ext4_utils/ext4_utils.c | 2 | ||||
-rw-r--r-- | ext4_utils/ext4_utils.h | 7 | ||||
-rw-r--r-- | ext4_utils/make_ext4fs.c | 6 | ||||
-rw-r--r-- | fatblock/fat.c | 2 | ||||
-rw-r--r-- | fatblock/fs.c | 2 | ||||
-rw-r--r-- | libublock/Android.mk | 2 | ||||
-rw-r--r-- | tests/Android.mk | 2 | ||||
-rw-r--r-- | tests/bionic/libc/Android.mk | 10 | ||||
-rw-r--r-- | tests/bionic/libc/bionic/test_dlclose_destruction.c | 4 | ||||
-rw-r--r-- | tests/bionic/libc/common/test_clock.c | 56 | ||||
-rw-r--r-- | tests/bionic/libc/common/test_strptime.c | 44 | ||||
-rwxr-xr-x | tests/bionic/libc/run-test.sh | 2 | ||||
-rw-r--r-- | tests/framebuffer/fb_test.c | 169 | ||||
-rw-r--r-- | tests/icachetest/Android.mk | 3 | ||||
-rw-r--r-- | tests/lib/testUtil/Android.mk | 2 | ||||
-rw-r--r-- | tests/memtest/Android.mk | 3 |
18 files changed, 244 insertions, 81 deletions
diff --git a/ext4_utils/Android.mk b/ext4_utils/Android.mk index 57d09965..417c839e 100644 --- a/ext4_utils/Android.mk +++ b/ext4_utils/Android.mk @@ -22,7 +22,7 @@ LOCAL_MODULE := libext4_utils LOCAL_MODULE_TAGS := optional LOCAL_C_INCLUDES += external/zlib LOCAL_SHARED_LIBRARIES := libz -LOCAL_PRELINK_MODULE := false + include $(BUILD_SHARED_LIBRARY) @@ -33,7 +33,7 @@ LOCAL_MODULE := libext4_utils LOCAL_MODULE_TAGS := optional LOCAL_C_INCLUDES += external/zlib LOCAL_STATIC_LIBRARIES := libz -LOCAL_PRELINK_MODULE := false + include $(BUILD_STATIC_LIBRARY) diff --git a/ext4_utils/contents.c b/ext4_utils/contents.c index ba7e05f3..c7607ab1 100644 --- a/ext4_utils/contents.c +++ b/ext4_utils/contents.c @@ -39,6 +39,11 @@ static u32 dentry_size(u32 entries, struct dentry *dentries) len += dentry_len; } + /* include size of the dentry used to pad until the end of the block */ + if (len % info.block_size + 8 > info.block_size) + len += info.block_size - (len % info.block_size); + len += 8; + return len; } diff --git a/ext4_utils/ext4_utils.c b/ext4_utils/ext4_utils.c index 211448c6..f4f04d90 100644 --- a/ext4_utils/ext4_utils.c +++ b/ext4_utils/ext4_utils.c @@ -42,6 +42,8 @@ int force = 0; struct fs_info info; struct fs_aux_info aux_info; +jmp_buf setjmp_env; + /* returns 1 if a is a power of b */ static int is_power_of(int a, int b) { diff --git a/ext4_utils/ext4_utils.h b/ext4_utils/ext4_utils.h index bed9933b..4518b98d 100644 --- a/ext4_utils/ext4_utils.h +++ b/ext4_utils/ext4_utils.h @@ -29,6 +29,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <setjmp.h> #if defined(__APPLE__) && defined(__MACH__) #define lseek64 lseek @@ -49,9 +50,9 @@ static inline void *mmap64(void *addr, size_t length, int prot, int flags, extern int force; #define warn(fmt, args...) do { fprintf(stderr, "warning: %s: " fmt "\n", __func__, ## args); } while (0) -#define error(fmt, args...) do { fprintf(stderr, "error: %s: " fmt "\n", __func__, ## args); if (!force) exit(EXIT_FAILURE); } while (0) +#define error(fmt, args...) do { fprintf(stderr, "error: %s: " fmt "\n", __func__, ## args); if (!force) longjmp(setjmp_env, EXIT_FAILURE); } while (0) #define error_errno(s, args...) error(s ": %s", ##args, strerror(errno)) -#define critical_error(fmt, args...) do { fprintf(stderr, "critical error: %s: " fmt "\n", __func__, ## args); exit(EXIT_FAILURE); } while (0) +#define critical_error(fmt, args...) do { fprintf(stderr, "critical error: %s: " fmt "\n", __func__, ## args); longjmp(setjmp_env, EXIT_FAILURE); } while (0) #define critical_error_errno(s, args...) critical_error(s ": %s", ##args, strerror(errno)) #define EXT4_SUPER_MAGIC 0xEF53 @@ -130,6 +131,8 @@ struct fs_aux_info { extern struct fs_info info; extern struct fs_aux_info aux_info; +extern jmp_buf setjmp_env; + static inline int log_2(int j) { int i; diff --git a/ext4_utils/make_ext4fs.c b/ext4_utils/make_ext4fs.c index a87529df..22c94244 100644 --- a/ext4_utils/make_ext4fs.c +++ b/ext4_utils/make_ext4fs.c @@ -214,7 +214,8 @@ static u32 compute_inodes_per_group() { u32 blocks = DIV_ROUND_UP(info.len, info.block_size); u32 block_groups = DIV_ROUND_UP(blocks, info.blocks_per_group); - return DIV_ROUND_UP(info.inodes, block_groups); + u32 inodes = DIV_ROUND_UP(info.inodes, block_groups); + return ALIGN(inodes, (info.block_size / info.inode_size)); } static u32 compute_bg_desc_reserve_blocks() @@ -256,6 +257,9 @@ int make_ext4fs_internal(const char *filename, const char *directory, u32 root_inode_num; u16 root_mode; + if (setjmp(setjmp_env)) + return EXIT_FAILURE; /* Handle a call to longjmp() */ + if (info.len <= 0) info.len = get_file_size(filename); diff --git a/fatblock/fat.c b/fatblock/fat.c index 02e32922..c549bc1b 100644 --- a/fatblock/fat.c +++ b/fatblock/fat.c @@ -16,7 +16,7 @@ #include <assert.h> #include <string.h> -#include <sys/endian.h> +#include <endian.h> #include "fat.h" diff --git a/fatblock/fs.c b/fatblock/fs.c index 5ab33d7b..fb19a705 100644 --- a/fatblock/fs.c +++ b/fatblock/fs.c @@ -16,7 +16,7 @@ #include <assert.h> #include <string.h> -#include <sys/endian.h> +#include <endian.h> #include "fatblock.h" #include "fat.h" diff --git a/libublock/Android.mk b/libublock/Android.mk index 50663ecf..690c5e8e 100644 --- a/libublock/Android.mk +++ b/libublock/Android.mk @@ -19,5 +19,5 @@ LOCAL_MODULE := libublock LOCAL_MODULE_TAGS := optional LOCAL_SRC_FILES := ublock.c LOCAL_C_INCLUDES := $(LOCAL_PATH)/include -LOCAL_PRELINK_MODULE := false + include $(BUILD_SHARED_LIBRARY) diff --git a/tests/Android.mk b/tests/Android.mk index 582ddc90..5053e7d6 100644 --- a/tests/Android.mk +++ b/tests/Android.mk @@ -1,3 +1 @@ -ifeq ($(TARGET_ARCH),arm) include $(call all-subdir-makefiles) -endif diff --git a/tests/bionic/libc/Android.mk b/tests/bionic/libc/Android.mk index 594565d9..5dcf130a 100644 --- a/tests/bionic/libc/Android.mk +++ b/tests/bionic/libc/Android.mk @@ -61,6 +61,7 @@ endef # First, the tests in 'common' sources := \ + common/test_clock.c \ common/test_cpu_set.c \ common/test_drand48.c \ common/test_executable_destructor.c \ @@ -78,6 +79,7 @@ sources := \ common/test_seteuid.c \ common/test_static_cpp_mutex.cpp \ common/test_strftime_2039.c \ + common/test_strptime.c \ common/test_tm_zone.c \ common/test_udp.c \ @@ -169,7 +171,7 @@ $(call device-test, $(sources)) include $(CLEAR_VARS) LOCAL_SRC_FILES := bionic/lib_relocs.c LOCAL_MODULE := libtest_relocs -LOCAL_PRELINK_MODULE := false + LOCAL_MODULE_TAGS := tests include $(BUILD_SHARED_LIBRARY) @@ -188,7 +190,7 @@ include $(BUILD_EXECUTABLE) include $(CLEAR_VARS) LOCAL_SRC_FILES := bionic/lib_static_init.cpp LOCAL_MODULE := libtest_static_init -LOCAL_PRELINK_MODULE := false + LOCAL_MODULE_TAGS := tests include $(BUILD_SHARED_LIBRARY) @@ -204,7 +206,7 @@ include $(BUILD_EXECUTABLE) include $(CLEAR_VARS) LOCAL_SRC_FILES := bionic/libdlclosetest1.cpp LOCAL_MODULE := libdlclosetest1 -LOCAL_PRELINK_MODULE := false + LOCAL_MODULE_TAGS := tests include $(BUILD_SHARED_LIBRARY) @@ -213,7 +215,7 @@ include $(BUILD_SHARED_LIBRARY) include $(CLEAR_VARS) LOCAL_SRC_FILES := bionic/libdlclosetest2.c LOCAL_MODULE := libdlclosetest2 -LOCAL_PRELINK_MODULE := false + LOCAL_MODULE_TAGS := tests include $(BUILD_SHARED_LIBRARY) diff --git a/tests/bionic/libc/bionic/test_dlclose_destruction.c b/tests/bionic/libc/bionic/test_dlclose_destruction.c index 928057a1..348df17e 100644 --- a/tests/bionic/libc/bionic/test_dlclose_destruction.c +++ b/tests/bionic/libc/bionic/test_dlclose_destruction.c @@ -76,6 +76,10 @@ check_library(const char* libname) } fprintf(stderr, "%s unloaded.\n", libname); + if (y != 2) { + fprintf(stderr, "Static destructors was not called on dlclose()!\n"); + return 2; + } return 0; } diff --git a/tests/bionic/libc/common/test_clock.c b/tests/bionic/libc/common/test_clock.c new file mode 100644 index 00000000..6d3752e3 --- /dev/null +++ b/tests/bionic/libc/common/test_clock.c @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2011 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. + */ + +// Minimal test program for clock + +#include <pthread.h> +#include <stdio.h> +#include <stdlib.h> +#include <time.h> +#include <unistd.h> + +// this thread soaks the CPU so that clock() function will advance +void *cpu_hog(void *arg) +{ + for (;;) { + // the system call should not be optimized away by the compiler + (void) getpid(); + } +} + +int main(int argc, char **argv) +{ + pthread_t thread; + clock_t ticks10, ticks15; + + // do not call clock() here so we can test initialization + + // soak the CPU for 10 seconds, then read clock + pthread_create(&thread, NULL, cpu_hog, NULL); + sleep(10); + ticks10 = clock(); + + // soak the CPU for 5 more seconds, then read clock + sleep(5); + ticks15 = clock(); + + // print the results + printf("CLOCKS_PER_SEC = %ld ticks/sec\n", (clock_t) CLOCKS_PER_SEC); + printf("At 10 secs clock=%lu, at 15 secs clock=%lu\n", ticks10, ticks15); + + // exit could wait for the other thread to complete + _exit(EXIT_SUCCESS); +} diff --git a/tests/bionic/libc/common/test_strptime.c b/tests/bionic/libc/common/test_strptime.c new file mode 100644 index 00000000..3cfc03bb --- /dev/null +++ b/tests/bionic/libc/common/test_strptime.c @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2011 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. + */ + +// Minimal test program for strptime + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> + +int main(int argc, char **argv) +{ + struct tm tm; + char buf[255]; + + // For now, only test a couple of formats that use recursion + + memset(&tm, 0, sizeof(tm)); + strptime("11:14", "%R", &tm); + strftime(buf, sizeof(buf), "%H:%M", &tm); + puts(buf); + puts(!strcmp(buf, "11:14") ? "OK" : "FAILED"); + + memset(&tm, 0, sizeof(tm)); + strptime("09:41:53", "%T", &tm); + strftime(buf, sizeof(buf), "%H:%M:%S", &tm); + puts(buf); + puts(!strcmp(buf, "09:41:53") ? "OK" : "FAILED"); + + return EXIT_SUCCESS; +} diff --git a/tests/bionic/libc/run-test.sh b/tests/bionic/libc/run-test.sh index bd9b25ed..c88c6fe0 100755 --- a/tests/bionic/libc/run-test.sh +++ b/tests/bionic/libc/run-test.sh @@ -165,7 +165,7 @@ set_adb_cmd_log $TMPDIR/adb.log.txt DEVICE_TEST_DIR=/data/local/bionic-test DEVICE_TEST=$DEVICE_TEST_DIR/$TESTNAME -adb_cmd mkdir -p $DEVICE_TEST_DIR +adb_cmd mkdir $DEVICE_TEST_DIR $ADB_CMD push $TESTEXE $DEVICE_TEST_DIR/ if [ $? != 0 ] ; then echo "ERROR: Can't push test to device!" diff --git a/tests/framebuffer/fb_test.c b/tests/framebuffer/fb_test.c index 39435063..0b8bc68c 100644 --- a/tests/framebuffer/fb_test.c +++ b/tests/framebuffer/fb_test.c @@ -28,19 +28,15 @@ #include <linux/fb.h> #include <linux/kd.h> -#include <pixelflinger/pixelflinger.h> - -#include "minui.h" - -typedef struct { - GGLSurface texture; - unsigned cwidth; - unsigned cheight; - unsigned ascent; -} GRFont; - -static GGLContext *gr_context = 0; -static GGLSurface gr_framebuffer[2]; +struct simple_fb { + void *data; + int width; + int height; + int stride; + int bpp; +}; + +static struct simple_fb gr_fbs[2]; static unsigned gr_active_fb = 0; static int gr_fb_fd = -1; @@ -53,10 +49,11 @@ struct timespec tv, tv2; static void dumpinfo(struct fb_fix_screeninfo *fi, struct fb_var_screeninfo *vi); -static int get_framebuffer(GGLSurface *fb) +static int get_framebuffer(struct simple_fb *fb, unsigned bpp) { int fd; void *bits; + int bytes_per_pixel; fd = open("/dev/graphics/fb0", O_RDWR); if (fd < 0) { @@ -67,12 +64,21 @@ static int get_framebuffer(GGLSurface *fb) } } - if(ioctl(fd, FBIOGET_FSCREENINFO, &fi) < 0) { + if(ioctl(fd, FBIOGET_VSCREENINFO, &vi) < 0) { perror("failed to get fb0 info"); return -1; } - if(ioctl(fd, FBIOGET_VSCREENINFO, &vi) < 0) { + if (bpp && vi.bits_per_pixel != bpp) { + printf("bpp != %d, forcing...\n", bpp); + vi.bits_per_pixel = bpp; + if(ioctl(fd, FBIOPUT_VSCREENINFO, &vi) < 0) { + perror("failed to force bpp"); + return -1; + } + } + + if(ioctl(fd, FBIOGET_FSCREENINFO, &fi) < 0) { perror("failed to get fb0 info"); return -1; } @@ -85,21 +91,22 @@ static int get_framebuffer(GGLSurface *fb) return -1; } - fb->version = sizeof(*fb); + bytes_per_pixel = vi.bits_per_pixel >> 3; + fb->width = vi.xres; fb->height = vi.yres; - fb->stride = fi.line_length / (vi.bits_per_pixel >> 3); + fb->stride = fi.line_length / bytes_per_pixel; fb->data = bits; - fb->format = GGL_PIXEL_FORMAT_RGB_565; + fb->bpp = vi.bits_per_pixel; fb++; - fb->version = sizeof(*fb); fb->width = vi.xres; fb->height = vi.yres; - fb->stride = fi.line_length / (vi.bits_per_pixel >> 3); - fb->data = (void*) (((unsigned) bits) + vi.yres * vi.xres * 2); - fb->format = GGL_PIXEL_FORMAT_RGB_565; + fb->stride = fi.line_length / bytes_per_pixel; + fb->data = (void *)((unsigned long)bits + + vi.yres * vi.xres * bytes_per_pixel); + fb->bpp = vi.bits_per_pixel; return fd; } @@ -129,7 +136,7 @@ static void dumpinfo(struct fb_fix_screeninfo *fi, struct fb_var_screeninfo *vi) } -int gr_init(void) +int gr_init(int bpp, int id) { int fd = -1; @@ -144,7 +151,7 @@ int gr_init(void) } } - gr_fb_fd = get_framebuffer(gr_framebuffer); + gr_fb_fd = get_framebuffer(gr_fbs, bpp); if(gr_fb_fd < 0) { if (fd >= 0) { @@ -157,8 +164,8 @@ int gr_init(void) gr_vt_fd = fd; /* start with 0 as front (displayed) and 1 as back (drawing) */ - gr_active_fb = 0; - set_active_framebuffer(0); + gr_active_fb = id; + set_active_framebuffer(id); return 0; } @@ -177,67 +184,103 @@ void gr_exit(void) int gr_fb_width(void) { - return gr_framebuffer[0].width; + return gr_fbs[0].width; } int gr_fb_height(void) { - return gr_framebuffer[0].height; + return gr_fbs[0].height; } uint16_t red = 0xf800; uint16_t green = 0x07e0; uint16_t blue = 0x001f; +uint16_t white = 0xffff; +uint16_t black = 0x0; + +uint32_t red32 = 0x00ff0000; +uint32_t green32 = 0x0000ff00; +uint32_t blue32 = 0x000000ff; +uint32_t white32 = 0x00ffffff; +uint32_t black32 = 0x0; + +void draw_grid(int w, int h, void* _loc) { + int i, j; + int v; + int stride = fi.line_length / (vi.bits_per_pixel >> 3); + uint16_t *loc = _loc; + uint32_t *loc32 = _loc; + + for (j = 0; j < h/2; j++) { + for (i = 0; i < w/2; i++) + if (vi.bits_per_pixel == 16) + loc[i + j*(stride)] = red; + else + loc32[i + j*(stride)] = red32; + for (; i < w; i++) + if (vi.bits_per_pixel == 16) + loc[i + j*(stride)] = green; + else + loc32[i + j*(stride)] = green32; + } -void draw_grid(int w, int h, uint16_t* loc) { - int i, j; - int v; - int stride = fi.line_length / (vi.bits_per_pixel >> 3); - - for (j = 0; j < h/2; j++) { - for (i = 0; i < w/2; i++) - loc[i + j*(stride)] = red; - for (; i < w; i++) - loc[i + j*(stride)] = green; - } - for (; j < h; j++) { - for (i = 0; i < w/2; i++) - loc[i + j*(stride)] = blue; - for (; i < w; i++) - loc[i + j*(stride)] = 0xffff; - } + for (; j < h; j++) { + for (i = 0; i < w/2; i++) + if (vi.bits_per_pixel == 16) + loc[i + j*(stride)] = blue; + else + loc32[i + j*(stride)] = blue32; + for (; i < w; i++) + if (vi.bits_per_pixel == 16) + loc[i + j*(stride)] = white; + else + loc32[i + j*(stride)] = white32; + } } -void clear_screen(int w, int h, uint16_t* loc) +void clear_screen(int w, int h, void* _loc) { int i,j; int stride = fi.line_length / (vi.bits_per_pixel >> 3); - - for (j = 0; j < h; j++) - for (i = 0; i < w; i++) - loc[i + j*(stride)] = 0x0000; + uint16_t *loc = _loc; + uint32_t *loc32 = _loc; + + for (j = 0; j < h; j++) + for (i = 0; i < w; i++) + if (vi.bits_per_pixel == 16) + loc[i + j*(stride)] = black; + else + loc32[i + j*(stride)] = black32; } 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]); + int bpp = 0; + + if (argc > 1) + bpp = atoi(argv[1]); + + if (argc > 4) + id = !!atoi(argv[4]); + + gr_init(bpp, id); + + if (argc > 3) { + w = atoi(argv[2]); + h = atoi(argv[3]); + } else { + w = vi.xres; + h = vi.yres; } - if (argc > 3) - id = !!atoi(argv[3]); + clear_screen(vi.xres, vi.yres, gr_fbs[0].data); + clear_screen(vi.xres, vi.yres, gr_fbs[1].data); + + draw_grid(w, h, gr_fbs[id].data); - draw_grid(w, h, (uint16_t *)gr_framebuffer[id].data); set_active_framebuffer(!id); set_active_framebuffer(id); diff --git a/tests/icachetest/Android.mk b/tests/icachetest/Android.mk index 39d0016f..f50f7909 100644 --- a/tests/icachetest/Android.mk +++ b/tests/icachetest/Android.mk @@ -1,5 +1,5 @@ # Copyright 2006 The Android Open Source Project - +ifeq ($(TARGET_ARCH),arm) LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) @@ -12,3 +12,4 @@ LOCAL_MODULE:= icache LOCAL_MODULE_TAGS := optional include $(BUILD_EXECUTABLE) +endif diff --git a/tests/lib/testUtil/Android.mk b/tests/lib/testUtil/Android.mk index 42758aeb..f814dac3 100644 --- a/tests/lib/testUtil/Android.mk +++ b/tests/lib/testUtil/Android.mk @@ -23,6 +23,6 @@ LOCAL_SRC_FILES:= testUtil.c LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../include LOCAL_CFLAGS += -std=c99 LOCAL_SHARED_LIBRARIES += libcutils libutils -LOCAL_PRELINK_MODULE := false + include $(BUILD_STATIC_LIBRARY) diff --git a/tests/memtest/Android.mk b/tests/memtest/Android.mk index 7fc6c0a9..3b893f60 100644 --- a/tests/memtest/Android.mk +++ b/tests/memtest/Android.mk @@ -1,5 +1,5 @@ # Copyright 2006 The Android Open Source Project - +ifeq ($(TARGET_ARCH),arm) LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) @@ -18,3 +18,4 @@ LOCAL_MODULE_TAGS := optional LOCAL_CFLAGS += -fomit-frame-pointer include $(BUILD_EXECUTABLE) +endif |