2007-01-22 23:29:39 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2007 Jens Arnold
|
|
|
|
*
|
2008-06-28 18:10:04 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2007-01-22 23:29:39 +00:00
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include "plugin.h"
|
2008-11-20 11:27:31 +00:00
|
|
|
#include "lib/helper.h"
|
2007-01-22 23:29:39 +00:00
|
|
|
|
2010-08-24 14:30:46 +00:00
|
|
|
|
2007-01-22 23:29:39 +00:00
|
|
|
|
2011-12-25 20:11:18 +00:00
|
|
|
#define TESTBASEDIR HOME_DIR "/__TEST__"
|
2007-05-22 20:49:22 +00:00
|
|
|
#define TEST_FILE TESTBASEDIR "/test_disk.tmp"
|
|
|
|
#define FRND_SEED 0x78C3 /* arbirary */
|
2007-01-22 23:29:39 +00:00
|
|
|
|
2012-03-22 17:36:27 +00:00
|
|
|
#if (CONFIG_STORAGE & STORAGE_MMC)
|
2007-01-22 23:29:39 +00:00
|
|
|
#define TEST_SIZE (20*1024*1024)
|
2012-03-22 17:36:27 +00:00
|
|
|
#else
|
|
|
|
#define TEST_SIZE (300*1024*1024)
|
|
|
|
#endif
|
2007-05-22 20:49:22 +00:00
|
|
|
#define TEST_TIME 10 /* in seconds */
|
2007-01-22 23:29:39 +00:00
|
|
|
|
|
|
|
static unsigned char* audiobuf;
|
2010-11-21 14:36:44 +00:00
|
|
|
static size_t audiobuflen;
|
2007-01-22 23:29:39 +00:00
|
|
|
|
|
|
|
static unsigned short frnd_buffer;
|
|
|
|
static int line = 0;
|
|
|
|
static int max_line = 0;
|
2007-05-22 20:49:22 +00:00
|
|
|
static int log_fd;
|
|
|
|
static char logfilename[MAX_PATH];
|
|
|
|
static const char testbasedir[] = TESTBASEDIR;
|
2007-01-22 23:29:39 +00:00
|
|
|
|
|
|
|
static void mem_fill_frnd(unsigned char *addr, int len)
|
|
|
|
{
|
|
|
|
unsigned char *end = addr + len;
|
|
|
|
unsigned random = frnd_buffer;
|
|
|
|
|
|
|
|
while (addr < end)
|
|
|
|
{
|
|
|
|
random = 75 * random + 74;
|
|
|
|
*addr++ = random >> 8;
|
|
|
|
}
|
|
|
|
frnd_buffer = random;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool mem_cmp_frnd(unsigned char *addr, int len)
|
|
|
|
{
|
|
|
|
unsigned char *end = addr + len;
|
|
|
|
unsigned random = frnd_buffer;
|
|
|
|
|
|
|
|
while (addr < end)
|
|
|
|
{
|
|
|
|
random = 75 * random + 74;
|
|
|
|
if (*addr++ != ((random >> 8) & 0xff))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
frnd_buffer = random;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2007-05-22 20:49:22 +00:00
|
|
|
static bool log_init(void)
|
2007-01-22 23:29:39 +00:00
|
|
|
{
|
|
|
|
int h;
|
|
|
|
|
|
|
|
rb->lcd_getstringsize("A", NULL, &h);
|
|
|
|
max_line = LCD_HEIGHT / h;
|
|
|
|
line = 0;
|
|
|
|
rb->lcd_clear_display();
|
|
|
|
rb->lcd_update();
|
2007-05-22 20:49:22 +00:00
|
|
|
|
2011-12-25 20:11:18 +00:00
|
|
|
rb->create_numbered_filename(logfilename, HOME_DIR, "test_disk_log_", ".txt",
|
2007-05-22 20:49:22 +00:00
|
|
|
2 IF_CNFN_NUM_(, NULL));
|
2010-05-06 17:35:13 +00:00
|
|
|
log_fd = rb->open(logfilename, O_RDWR|O_CREAT|O_TRUNC, 0666);
|
2007-05-22 20:49:22 +00:00
|
|
|
return log_fd >= 0;
|
2007-01-22 23:29:39 +00:00
|
|
|
}
|
|
|
|
|
2007-05-22 20:49:22 +00:00
|
|
|
static void log_text(char *text, bool advance)
|
2007-01-22 23:29:39 +00:00
|
|
|
{
|
|
|
|
rb->lcd_puts(0, line, text);
|
|
|
|
rb->lcd_update();
|
|
|
|
if (advance)
|
2007-05-22 20:49:22 +00:00
|
|
|
{
|
2007-01-22 23:29:39 +00:00
|
|
|
if (++line >= max_line)
|
|
|
|
line = 0;
|
2007-05-22 20:49:22 +00:00
|
|
|
rb->fdprintf(log_fd, "%s\n", text);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void log_close(void)
|
|
|
|
{
|
|
|
|
rb->close(log_fd);
|
2007-01-22 23:29:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool test_fs(void)
|
|
|
|
{
|
|
|
|
unsigned char text_buf[32];
|
2007-05-22 20:49:22 +00:00
|
|
|
int total, current, align;
|
2010-06-15 08:55:28 +00:00
|
|
|
int fd, ret;
|
2007-01-22 23:29:39 +00:00
|
|
|
|
|
|
|
log_init();
|
2007-05-22 20:49:22 +00:00
|
|
|
log_text("test_disk WRITE&VERIFY", true);
|
2010-06-21 16:53:00 +00:00
|
|
|
#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
|
2007-05-22 20:49:22 +00:00
|
|
|
rb->snprintf(text_buf, sizeof(text_buf), "CPU clock: %ld Hz",
|
|
|
|
*rb->cpu_frequency);
|
|
|
|
log_text(text_buf, true);
|
2007-08-05 20:41:49 +00:00
|
|
|
#endif
|
2007-05-22 20:49:22 +00:00
|
|
|
log_text("----------------------", true);
|
|
|
|
rb->snprintf(text_buf, sizeof text_buf, "Data size: %dKB", (TEST_SIZE>>10));
|
|
|
|
log_text(text_buf, true);
|
2007-01-22 23:29:39 +00:00
|
|
|
|
2010-05-06 17:35:04 +00:00
|
|
|
fd = rb->creat(TEST_FILE, 0666);
|
2007-01-22 23:29:39 +00:00
|
|
|
if (fd < 0)
|
|
|
|
{
|
2010-06-15 08:55:28 +00:00
|
|
|
rb->splashf(HZ, "creat() failed: %d", fd);
|
2007-01-22 23:29:39 +00:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
frnd_buffer = FRND_SEED;
|
|
|
|
total = TEST_SIZE;
|
|
|
|
while (total > 0)
|
|
|
|
{
|
2010-05-02 19:38:23 +00:00
|
|
|
align = rb->rand() & 0xf;
|
|
|
|
current = rb->rand() % (audiobuflen - align);
|
2007-01-22 23:29:39 +00:00
|
|
|
current = MIN(current, total);
|
|
|
|
rb->snprintf(text_buf, sizeof text_buf, "Wrt %dKB, %dKB left",
|
|
|
|
current >> 10, total >> 10);
|
2007-05-22 20:49:22 +00:00
|
|
|
log_text(text_buf, false);
|
2007-01-22 23:29:39 +00:00
|
|
|
|
2007-05-22 20:49:22 +00:00
|
|
|
mem_fill_frnd(audiobuf + align, current);
|
2010-06-15 08:55:28 +00:00
|
|
|
ret = rb->write(fd, audiobuf + align, current);
|
|
|
|
if (current != ret)
|
2007-01-22 23:29:39 +00:00
|
|
|
{
|
2010-06-15 08:55:28 +00:00
|
|
|
rb->splashf(0, "write() failed: %d/%d", ret, current);
|
2007-01-22 23:29:39 +00:00
|
|
|
rb->close(fd);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
total -= current;
|
|
|
|
}
|
|
|
|
rb->close(fd);
|
|
|
|
|
|
|
|
fd = rb->open(TEST_FILE, O_RDONLY);
|
|
|
|
if (fd < 0)
|
|
|
|
{
|
2010-06-15 08:55:28 +00:00
|
|
|
rb->splashf(0, "open() failed: %d", ret);
|
2007-01-22 23:29:39 +00:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
frnd_buffer = FRND_SEED;
|
|
|
|
total = TEST_SIZE;
|
|
|
|
while (total > 0)
|
|
|
|
{
|
2010-05-02 19:38:23 +00:00
|
|
|
align = rb->rand() & 0xf;
|
|
|
|
current = rb->rand() % (audiobuflen - align);
|
2007-01-22 23:29:39 +00:00
|
|
|
current = MIN(current, total);
|
|
|
|
rb->snprintf(text_buf, sizeof text_buf, "Cmp %dKB, %dKB left",
|
|
|
|
current >> 10, total >> 10);
|
2007-05-22 20:49:22 +00:00
|
|
|
log_text(text_buf, false);
|
2007-01-22 23:29:39 +00:00
|
|
|
|
2010-06-15 08:55:28 +00:00
|
|
|
ret = rb->read(fd, audiobuf + align, current);
|
|
|
|
if (current != ret)
|
2007-01-22 23:29:39 +00:00
|
|
|
{
|
2010-06-15 08:55:28 +00:00
|
|
|
rb->splashf(0, "read() failed: %d/%d", ret, current);
|
2007-01-22 23:29:39 +00:00
|
|
|
rb->close(fd);
|
|
|
|
goto error;
|
|
|
|
}
|
2007-05-22 20:49:22 +00:00
|
|
|
if (!mem_cmp_frnd(audiobuf + align, current))
|
2007-01-22 23:29:39 +00:00
|
|
|
{
|
2007-05-22 20:49:22 +00:00
|
|
|
log_text(text_buf, true);
|
|
|
|
log_text("Compare error.", true);
|
2007-01-22 23:29:39 +00:00
|
|
|
rb->close(fd);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
total -= current;
|
|
|
|
}
|
|
|
|
rb->close(fd);
|
2007-05-22 20:49:22 +00:00
|
|
|
log_text(text_buf, true);
|
|
|
|
log_text("Test passed.", true);
|
2007-01-22 23:29:39 +00:00
|
|
|
|
|
|
|
error:
|
2007-05-22 20:49:22 +00:00
|
|
|
log_close();
|
2007-01-22 23:29:39 +00:00
|
|
|
rb->remove(TEST_FILE);
|
|
|
|
rb->button_clear_queue();
|
|
|
|
rb->button_get(true);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-05-22 20:49:22 +00:00
|
|
|
static bool file_speed(int chunksize, bool align)
|
2007-01-22 23:29:39 +00:00
|
|
|
{
|
2007-05-22 20:49:22 +00:00
|
|
|
unsigned char text_buf[64];
|
2010-06-15 08:55:28 +00:00
|
|
|
int fd, ret;
|
2007-05-22 20:49:22 +00:00
|
|
|
long filesize = 0;
|
|
|
|
long size, time;
|
|
|
|
|
2010-11-21 14:36:44 +00:00
|
|
|
if ((unsigned)chunksize >= audiobuflen)
|
2007-05-22 20:49:22 +00:00
|
|
|
return false;
|
2007-01-22 23:29:39 +00:00
|
|
|
|
2007-05-22 20:49:22 +00:00
|
|
|
log_text("--------------------", true);
|
2007-01-22 23:29:39 +00:00
|
|
|
|
2007-05-22 20:49:22 +00:00
|
|
|
/* File creation write speed */
|
2010-05-06 17:35:04 +00:00
|
|
|
fd = rb->creat(TEST_FILE, 0666);
|
2007-01-22 23:29:39 +00:00
|
|
|
if (fd < 0)
|
|
|
|
{
|
2010-06-15 08:55:28 +00:00
|
|
|
rb->splashf(HZ, "creat() failed: %d", fd);
|
2007-01-22 23:29:39 +00:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
time = *rb->current_tick;
|
2007-05-22 20:49:22 +00:00
|
|
|
while (TIME_BEFORE(*rb->current_tick, time + TEST_TIME*HZ))
|
2007-01-22 23:29:39 +00:00
|
|
|
{
|
2010-06-15 08:55:28 +00:00
|
|
|
ret = rb->write(fd, audiobuf + (align ? 0 : 1), chunksize);
|
|
|
|
if (chunksize != ret)
|
2007-05-22 20:49:22 +00:00
|
|
|
{
|
2010-06-15 08:55:28 +00:00
|
|
|
rb->splashf(HZ, "write() failed: %d/%d", ret, chunksize);
|
2007-05-22 20:49:22 +00:00
|
|
|
rb->close(fd);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
filesize += chunksize;
|
2007-01-22 23:29:39 +00:00
|
|
|
}
|
|
|
|
time = *rb->current_tick - time;
|
|
|
|
rb->close(fd);
|
2007-05-22 20:49:22 +00:00
|
|
|
rb->snprintf(text_buf, sizeof text_buf, "Create (%d,%c): %ld KB/s",
|
2008-02-26 18:31:59 +00:00
|
|
|
chunksize, align ? 'A' : 'U', (25 * (filesize>>8) / time) );
|
2007-05-22 20:49:22 +00:00
|
|
|
log_text(text_buf, true);
|
2007-01-22 23:29:39 +00:00
|
|
|
|
2007-05-22 20:49:22 +00:00
|
|
|
/* Existing file write speed */
|
2007-01-22 23:29:39 +00:00
|
|
|
fd = rb->open(TEST_FILE, O_WRONLY);
|
|
|
|
if (fd < 0)
|
|
|
|
{
|
2010-06-15 08:55:28 +00:00
|
|
|
rb->splashf(0, "open() failed: %d", fd);
|
2007-01-22 23:29:39 +00:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
time = *rb->current_tick;
|
2007-05-22 20:49:22 +00:00
|
|
|
for (size = filesize; size > 0; size -= chunksize)
|
2007-01-22 23:29:39 +00:00
|
|
|
{
|
2010-06-15 08:55:28 +00:00
|
|
|
ret = rb->write(fd, audiobuf + (align ? 0 : 1), chunksize);
|
|
|
|
if (chunksize != ret)
|
2007-05-22 20:49:22 +00:00
|
|
|
{
|
2010-06-15 08:55:28 +00:00
|
|
|
rb->splashf(0, "write() failed: %d/%d", ret, chunksize);
|
2007-05-22 20:49:22 +00:00
|
|
|
rb->close(fd);
|
|
|
|
goto error;
|
|
|
|
}
|
2007-01-22 23:29:39 +00:00
|
|
|
}
|
|
|
|
time = *rb->current_tick - time;
|
|
|
|
rb->close(fd);
|
2007-05-22 20:49:22 +00:00
|
|
|
rb->snprintf(text_buf, sizeof text_buf, "Write (%d,%c): %ld KB/s",
|
2008-02-26 18:31:59 +00:00
|
|
|
chunksize, align ? 'A' : 'U', (25 * (filesize>>8) / time) );
|
2007-05-22 20:49:22 +00:00
|
|
|
log_text(text_buf, true);
|
2007-01-22 23:29:39 +00:00
|
|
|
|
2007-05-22 20:49:22 +00:00
|
|
|
/* File read speed */
|
|
|
|
fd = rb->open(TEST_FILE, O_RDONLY);
|
2007-01-22 23:29:39 +00:00
|
|
|
if (fd < 0)
|
|
|
|
{
|
2010-06-15 08:55:28 +00:00
|
|
|
rb->splashf(0, "open() failed: %d", fd);
|
2007-01-22 23:29:39 +00:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
time = *rb->current_tick;
|
2007-05-22 20:49:22 +00:00
|
|
|
for (size = filesize; size > 0; size -= chunksize)
|
2007-01-22 23:29:39 +00:00
|
|
|
{
|
2010-06-15 08:55:28 +00:00
|
|
|
ret = rb->read(fd, audiobuf + (align ? 0 : 1), chunksize);
|
|
|
|
if (chunksize != ret)
|
2007-05-22 20:49:22 +00:00
|
|
|
{
|
2010-06-15 08:55:28 +00:00
|
|
|
rb->splashf(0, "read() failed: %d/%d", ret, chunksize);
|
2007-05-22 20:49:22 +00:00
|
|
|
rb->close(fd);
|
|
|
|
goto error;
|
|
|
|
}
|
2007-01-22 23:29:39 +00:00
|
|
|
}
|
|
|
|
time = *rb->current_tick - time;
|
|
|
|
rb->close(fd);
|
2007-05-22 20:49:22 +00:00
|
|
|
rb->snprintf(text_buf, sizeof text_buf, "Read (%d,%c): %ld KB/s",
|
2008-02-26 18:31:59 +00:00
|
|
|
chunksize, align ? 'A' : 'U', (25 * (filesize>>8) / time) );
|
2007-05-22 20:49:22 +00:00
|
|
|
log_text(text_buf, true);
|
|
|
|
rb->remove(TEST_FILE);
|
|
|
|
return true;
|
|
|
|
|
|
|
|
error:
|
|
|
|
rb->remove(TEST_FILE);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool test_speed(void)
|
|
|
|
{
|
|
|
|
unsigned char text_buf[64];
|
|
|
|
DIR *dir = NULL;
|
|
|
|
struct dirent *entry = NULL;
|
|
|
|
int fd, last_file;
|
|
|
|
int i, n;
|
|
|
|
long time;
|
|
|
|
|
|
|
|
rb->memset(audiobuf, 'T', audiobuflen);
|
|
|
|
log_init();
|
|
|
|
log_text("test_disk SPEED TEST", true);
|
2010-06-21 16:53:00 +00:00
|
|
|
#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
|
2007-05-22 20:49:22 +00:00
|
|
|
rb->snprintf(text_buf, sizeof(text_buf), "CPU clock: %ld Hz",
|
|
|
|
*rb->cpu_frequency);
|
|
|
|
log_text(text_buf, true);
|
2007-08-05 20:41:49 +00:00
|
|
|
#endif
|
2007-05-22 20:49:22 +00:00
|
|
|
log_text("--------------------", true);
|
|
|
|
|
|
|
|
/* File creation speed */
|
|
|
|
time = *rb->current_tick + TEST_TIME*HZ;
|
|
|
|
for (i = 0; TIME_BEFORE(*rb->current_tick, time); i++)
|
2007-01-22 23:29:39 +00:00
|
|
|
{
|
2007-05-22 20:49:22 +00:00
|
|
|
rb->snprintf(text_buf, sizeof(text_buf), TESTBASEDIR "/%08x.tmp", i);
|
2010-05-06 17:35:04 +00:00
|
|
|
fd = rb->creat(text_buf, 0666);
|
2007-05-22 20:49:22 +00:00
|
|
|
if (fd < 0)
|
|
|
|
{
|
|
|
|
last_file = i;
|
2010-06-15 08:55:28 +00:00
|
|
|
rb->splashf(HZ, "creat() failed: %d", fd);
|
2007-05-22 20:49:22 +00:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
rb->close(fd);
|
2007-01-22 23:29:39 +00:00
|
|
|
}
|
2007-05-22 20:49:22 +00:00
|
|
|
last_file = i;
|
|
|
|
rb->snprintf(text_buf, sizeof(text_buf), "Create: %d files/s",
|
|
|
|
last_file / TEST_TIME);
|
|
|
|
log_text(text_buf, true);
|
|
|
|
|
|
|
|
/* File open speed */
|
|
|
|
time = *rb->current_tick + TEST_TIME*HZ;
|
|
|
|
for (n = 0, i = 0; TIME_BEFORE(*rb->current_tick, time); n++, i++)
|
2007-01-22 23:29:39 +00:00
|
|
|
{
|
2007-05-22 20:49:22 +00:00
|
|
|
if (i >= last_file)
|
|
|
|
i = 0;
|
|
|
|
rb->snprintf(text_buf, sizeof(text_buf), TESTBASEDIR "/%08x.tmp", i);
|
|
|
|
fd = rb->open(text_buf, O_RDONLY);
|
|
|
|
if (fd < 0)
|
|
|
|
{
|
2010-06-15 08:55:28 +00:00
|
|
|
rb->splashf(HZ, "open() failed: %d", fd);
|
2007-05-22 20:49:22 +00:00
|
|
|
goto error;
|
|
|
|
}
|
2007-01-22 23:29:39 +00:00
|
|
|
rb->close(fd);
|
|
|
|
}
|
2007-05-22 20:49:22 +00:00
|
|
|
rb->snprintf(text_buf, sizeof(text_buf), "Open: %d files/s", n / TEST_TIME);
|
|
|
|
log_text(text_buf, true);
|
|
|
|
|
|
|
|
/* Directory scan speed */
|
|
|
|
time = *rb->current_tick + TEST_TIME*HZ;
|
|
|
|
for (n = 0; TIME_BEFORE(*rb->current_tick, time); n++)
|
2007-01-22 23:29:39 +00:00
|
|
|
{
|
2007-05-22 20:49:22 +00:00
|
|
|
if (entry == NULL)
|
|
|
|
{
|
|
|
|
if (dir != NULL)
|
|
|
|
rb->closedir(dir);
|
|
|
|
dir = rb->opendir(testbasedir);
|
|
|
|
if (dir == NULL)
|
|
|
|
{
|
|
|
|
rb->splash(HZ, "opendir() failed.");
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
entry = rb->readdir(dir);
|
2007-01-22 23:29:39 +00:00
|
|
|
}
|
2007-05-22 20:49:22 +00:00
|
|
|
rb->closedir(dir);
|
|
|
|
rb->snprintf(text_buf, sizeof(text_buf), "Dirscan: %d files/s", n / TEST_TIME);
|
|
|
|
log_text(text_buf, true);
|
|
|
|
|
2014-02-25 08:57:18 +00:00
|
|
|
dir = NULL;
|
|
|
|
entry = NULL;
|
|
|
|
/* Directory scan speed 2 */
|
|
|
|
time = *rb->current_tick + TEST_TIME*HZ;
|
|
|
|
for (n = 0; TIME_BEFORE(*rb->current_tick, time); n++)
|
|
|
|
{
|
|
|
|
if (entry == NULL)
|
|
|
|
{
|
|
|
|
if (dir != NULL)
|
|
|
|
rb->closedir(dir);
|
|
|
|
dir = rb->opendir(testbasedir);
|
|
|
|
if (dir == NULL)
|
|
|
|
{
|
|
|
|
rb->splash(HZ, "opendir() failed.");
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
(void) rb->dir_get_info(dir, entry);
|
|
|
|
entry = rb->readdir(dir);
|
|
|
|
}
|
|
|
|
rb->closedir(dir);
|
|
|
|
rb->snprintf(text_buf, sizeof(text_buf), "Dirscan w info: %d files/s", n / TEST_TIME);
|
|
|
|
log_text(text_buf, true);
|
|
|
|
|
2007-05-22 20:49:22 +00:00
|
|
|
/* File delete speed */
|
2007-01-22 23:29:39 +00:00
|
|
|
time = *rb->current_tick;
|
2007-05-22 20:49:22 +00:00
|
|
|
for (i = 0; i < last_file; i++)
|
2007-01-22 23:29:39 +00:00
|
|
|
{
|
2007-05-22 20:49:22 +00:00
|
|
|
rb->snprintf(text_buf, sizeof(text_buf), TESTBASEDIR "/%08x.tmp", i);
|
|
|
|
rb->remove(text_buf);
|
2007-01-22 23:29:39 +00:00
|
|
|
}
|
2007-05-22 20:49:22 +00:00
|
|
|
rb->snprintf(text_buf, sizeof(text_buf), "Delete: %ld files/s",
|
|
|
|
last_file * HZ / (*rb->current_tick - time));
|
|
|
|
log_text(text_buf, true);
|
|
|
|
|
|
|
|
if (file_speed(512, true)
|
|
|
|
&& file_speed(512, false)
|
|
|
|
&& file_speed(4096, true)
|
|
|
|
&& file_speed(4096, false)
|
|
|
|
&& file_speed(1048576, true))
|
|
|
|
file_speed(1048576, false);
|
|
|
|
|
|
|
|
log_text("DONE", false);
|
|
|
|
log_close();
|
2007-01-22 23:29:39 +00:00
|
|
|
rb->button_clear_queue();
|
|
|
|
rb->button_get(true);
|
2007-05-22 20:49:22 +00:00
|
|
|
return false;
|
2007-01-22 23:29:39 +00:00
|
|
|
|
2007-05-22 20:49:22 +00:00
|
|
|
error:
|
|
|
|
for (i = 0; i < last_file; i++)
|
|
|
|
{
|
|
|
|
rb->snprintf(text_buf, sizeof(text_buf), TESTBASEDIR "/%08x.tmp", i);
|
|
|
|
rb->remove(text_buf);
|
|
|
|
}
|
|
|
|
log_text("DONE", false);
|
|
|
|
log_close();
|
|
|
|
rb->button_clear_queue();
|
|
|
|
rb->button_get(true);
|
2007-01-22 23:29:39 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* this is the plugin entry point */
|
2009-01-16 10:34:40 +00:00
|
|
|
enum plugin_status plugin_start(const void* parameter)
|
2007-01-22 23:29:39 +00:00
|
|
|
{
|
2009-06-16 04:25:21 +00:00
|
|
|
MENUITEM_STRINGLIST(menu, "Test Disk Menu", NULL,
|
|
|
|
"Disk speed", "Write & verify");
|
|
|
|
int selected=0;
|
|
|
|
bool quit = false;
|
2007-05-22 20:49:22 +00:00
|
|
|
DIR *dir;
|
2007-01-22 23:29:39 +00:00
|
|
|
|
|
|
|
(void)parameter;
|
2007-05-22 20:49:22 +00:00
|
|
|
|
|
|
|
if ((dir = rb->opendir(testbasedir)) == NULL)
|
|
|
|
{
|
|
|
|
if (rb->mkdir(testbasedir) < 0)
|
|
|
|
{
|
|
|
|
rb->splash(HZ*2, "Can't create test directory.");
|
|
|
|
return PLUGIN_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rb->closedir(dir);
|
|
|
|
}
|
|
|
|
|
2010-11-21 14:36:44 +00:00
|
|
|
audiobuf = rb->plugin_get_audio_buffer(&audiobuflen);
|
2013-05-24 18:57:32 +00:00
|
|
|
#ifdef STORAGE_WANTS_ALIGN
|
|
|
|
/* align start and length for DMA */
|
|
|
|
STORAGE_ALIGN_BUFFER(audiobuf, audiobuflen);
|
|
|
|
#else
|
2007-05-22 20:49:22 +00:00
|
|
|
/* align start and length to 32 bit */
|
2013-05-24 18:57:32 +00:00
|
|
|
ALIGN_BUFFER(audiobuf, audiobuflen, 4);
|
|
|
|
#endif
|
2007-05-22 20:49:22 +00:00
|
|
|
|
2007-01-22 23:29:39 +00:00
|
|
|
rb->srand(*rb->current_tick);
|
|
|
|
|
2007-08-15 12:42:09 +00:00
|
|
|
/* Turn off backlight timeout */
|
2011-01-24 12:29:16 +00:00
|
|
|
backlight_ignore_timeout();
|
2007-01-22 23:29:39 +00:00
|
|
|
|
2009-06-16 04:25:21 +00:00
|
|
|
while(!quit)
|
|
|
|
{
|
|
|
|
switch(rb->do_menu(&menu, &selected, NULL, false))
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
test_speed();
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
test_fs();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
quit = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2007-01-22 23:29:39 +00:00
|
|
|
|
2007-08-15 12:42:09 +00:00
|
|
|
/* Turn on backlight timeout (revert to settings) */
|
2011-01-24 12:29:16 +00:00
|
|
|
backlight_use_settings();
|
2007-05-22 20:49:22 +00:00
|
|
|
|
|
|
|
rb->rmdir(testbasedir);
|
2007-01-22 23:29:39 +00:00
|
|
|
|
|
|
|
return PLUGIN_OK;
|
|
|
|
}
|