[-]
[+]
|
Changed |
memtester.spec
|
|
[-]
[+]
|
Changed |
memtester-4.3.0.tar.bz2/CHANGELOG
^
|
@@ -1,3 +1,13 @@
+Version 4.3.0
+9 June 2012
+ -add ability to mmap a device other than /dev/mem, enabling easier testing
+ of memory for hardware engineers et al if their system's kernel exports the
+ memory they're interested in via /dev/mydevice or similar. Thanks:
+ Jean-Noël Avila.
+ -add ability to run only specified tests by setting the environment
+ variable MEMTESTER_TEST_MASK to a bitmask of the indexes of the tests to be
+ run. Thanks: Ian Alexander.
+
Version 4.2.2
22 July 2011
-add progress message for one more errno value (EAGAIN) in response to failed
|
[-]
[+]
|
Changed |
memtester-4.3.0.tar.bz2/README
^
|
@@ -8,7 +8,7 @@
Version 2 Copyright 1999 Charles Cazabon.
Version 3 not publicly released.
Version 4 rewrite:
- Copyright 2004-2010 Charles Cazabon.
+ Copyright 2004-2012 Charles Cazabon.
Licensed under the terms of the GNU General Public License version 2 (only).
See the file COPYING for details.
@@ -84,8 +84,11 @@
[runs] is an optional limit to the number of runs through all tests.
An optional "-p physaddr" argument available to cause memtester to test
- memory starting at a specific physical memory address (by mmap'ing
- /dev/mem starting at an offset of `physaddr`, which is given in hex).
+ memory starting at a specific physical memory address (by mmap(2)ing
+ a device file representing physical memory (/dev/mem by default, but can
+ be specified with the "-d device" option) starting at an offset of
+ `physaddr`, which is given in hex).
+
Note: the memory specified will be overwritten during testing; you
therefore *cannot* specify a region belonging to the kernel or other
applications without causing the other process or entire system to
@@ -94,10 +97,18 @@
testing memory-mapped I/O devices and similar. Thanks to Allon Stern
for the idea behind this feature. For example, if you want to test a
bank of RAM or device which is 64kbytes in size and starts at physical
- address 0x0C0000, you would run memtester as follows:
+ address 0x0C0000 through the normal /dev/mem, you would run memtester as
+ follows:
memtester -p 0x0c0000 64k [runs]
+ If instead that device presented its memory as /dev/foodev at offset
+ 0, you would run memtester instead as follows:
+
+ memtester -p 0 -d /dev/foodev 64k [runs]
+
+ Note that the "-d" option can only be specified in combination with "-p".
+
memtester must run as user root so that it can lock its pages into
memory. If memtester fails to lock its pages, it will issue a warning and
continue regardless. Testing without the memory being locked is generally
|
[-]
[+]
|
Changed |
memtester-4.3.0.tar.bz2/memtester.8
^
|
@@ -1,9 +1,9 @@
-.TH memtester "8" "July 2009" "memtester 4" "Maintenance Commands"
+.TH memtester "8" "June 2012" "memtester 4" "Maintenance Commands"
.SH NAME
memtester \- stress test to find memory subsystem faults.
.SH SYNOPSIS
.B memtester
-[\f -p PHYSADDR\fR]
+[\f -p PHYSADDR\fR [\f -d DEVICE\fR]]
<\fIMEMORY\fR>
[\fIITERATIONS\fR]
.SH DESCRIPTION
@@ -47,8 +47,9 @@
.TP
\f -p PHYSADDR\fR
tells memtester to test a specific region of memory starting at physical
-address PHYSADDR (given in hex), by mmap(2)ing /dev/mem. This is mostly of
-use to hardware developers, for testing memory-mapped I/O devices and similar.
+address PHYSADDR (given in hex), by mmap(2)ing a device specified by the
+-d option (below, or /dev/mem by default). This is mostly of use to hardware
+developers, for testing memory-mapped I/O devices and similar.
Note that the memory region will be overwritten during testing, so it is not
safe to specify memory which is allocated for the system or for other
applications; doing so will cause them to crash. If you absolutely must test
@@ -63,6 +64,16 @@
.TP
\fIITERATIONS\fR
(optional) number of loops to iterate through. Default is infinite.
+.SH ENVIRONMENT
+.PP
+If the environment variable MEMTESTER_TEST_MASK is set, memtester treats the
+value as a bitmask of which tests (other than the stuck address test) to run.
+The value can be specified in decimal, in octal (with a leading 0), or in
+hexadecimal (with a leading 0x). The specific bit values corresponding to
+particular tests may change from release to release; consult the list of tests
+in the source for the appropriate index values for the version of memtester you
+are running. Note that skipping some tests will reduce the time it takes for
+memtester to run, but also reduce memtester's effectiveness.
.SH NOTE
.PP
memtester must be run with root privileges to mlock(3) its pages. Testing
@@ -86,7 +97,7 @@
Report bugs to <charlesc-memtester-bugs@pyropus.ca>.
.PP
.SH COPYRIGHT
-Copyright \(co 2009 Charles Cazabon
+Copyright \(co 2001-2012 Charles Cazabon
.br
This is free software; see the file COPYING for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
[-]
[+]
|
Changed |
memtester-4.3.0.tar.bz2/memtester.c
^
|
@@ -6,13 +6,13 @@
* Version 2 by Charles Cazabon <charlesc-memtester@pyropus.ca>
* Version 3 not publicly released.
* Version 4 rewrite:
- * Copyright (C) 2004-2010 Charles Cazabon <charlesc-memtester@pyropus.ca>
+ * Copyright (C) 2004-2012 Charles Cazabon <charlesc-memtester@pyropus.ca>
* Licensed under the terms of the GNU General Public License version 2 (only).
* See the file COPYING for details.
*
*/
-#define __version__ "4.2.2"
+#define __version__ "4.3.0"
#include <stddef.h>
#include <stdlib.h>
@@ -22,6 +22,7 @@
#include <sys/mman.h>
#include <unistd.h>
#include <fcntl.h>
+#include <string.h>
#include <errno.h>
#include "types.h"
@@ -100,7 +101,9 @@
/* Function definitions */
void usage(char *me) {
- fprintf(stderr, "\nUsage: %s [-p physaddrbase] <mem>[B|K|M|G] [loops]\n", me);
+ fprintf(stderr, "\n"
+ "Usage: %s [-p physaddrbase [-d device]] <mem>[B|K|M|G] [loops]\n",
+ me);
exit(EXIT_FAIL_NONSTARTER);
}
@@ -117,17 +120,37 @@
int memfd, opt, memshift;
size_t maxbytes = -1; /* addressable memory, in bytes */
size_t maxmb = (maxbytes >> 20) + 1; /* addressable memory, in MB */
+ /* Device to mmap memory from with -p, default is normal core */
+ char *device_name = "/dev/mem";
+ struct stat statbuf;
+ int device_specified = 0;
+ char *env_testmask = 0;
+ ul testmask = 0;
printf("memtester version " __version__ " (%d-bit)\n", UL_LEN);
- printf("Copyright (C) 2010 Charles Cazabon.\n");
+ printf("Copyright (C) 2001-2012 Charles Cazabon.\n");
printf("Licensed under the GNU General Public License version 2 (only).\n");
printf("\n");
check_posix_system();
pagesize = memtester_pagesize();
pagesizemask = (ptrdiff_t) ~(pagesize - 1);
printf("pagesizemask is 0x%tx\n", pagesizemask);
+
+ /* If MEMTESTER_TEST_MASK is set, we use its value as a mask of which
+ tests we run.
+ */
+ if (env_testmask = getenv("MEMTESTER_TEST_MASK")) {
+ errno = 0;
+ testmask = strtoul(env_testmask, 0, 0);
+ if (errno) {
+ fprintf(stderr, "error parsing MEMTESTER_TEST_MASK %s: %s\n",
+ env_testmask, strerror(errno));
+ usage(argv[0]); /* doesn't return */
+ }
+ printf("using testmask 0x%lx\n", testmask);
+ }
- while ((opt = getopt(argc, argv, "p:")) != -1) {
+ while ((opt = getopt(argc, argv, "p:d:")) != -1) {
switch (opt) {
case 'p':
errno = 0;
@@ -154,11 +177,33 @@
/* okay, got address */
use_phys = 1;
break;
+ case 'd':
+ if (stat(optarg,&statbuf)) {
+ fprintf(stderr, "can not use %s as device: %s\n", optarg,
+ strerror(errno));
+ usage(argv[0]); /* doesn't return */
+ } else {
+ if (!S_ISCHR(statbuf.st_mode)) {
+ fprintf(stderr, "can not mmap non-char device %s\n",
+ optarg);
+ usage(argv[0]); /* doesn't return */
+ } else {
+ device_name = optarg;
+ device_specified = 1;
+ }
+ }
+ break;
default: /* '?' */
usage(argv[0]); /* doesn't return */
}
}
+ if (device_specified && !use_phys) {
+ fprintf(stderr,
+ "for mem device, physaddrbase (-p) must be specified\n");
+ usage(argv[0]); /* doesn't return */
+ }
+
if (optind >= argc) {
fprintf(stderr, "need memory argument, in MB\n");
usage(argv[0]); /* doesn't return */
@@ -226,16 +271,18 @@
buf = NULL;
if (use_phys) {
- memfd = open("/dev/mem", O_RDWR | O_SYNC);
+ memfd = open(device_name, O_RDWR | O_SYNC);
if (memfd == -1) {
- perror("failed to open /dev/mem for physical memory");
+ fprintf(stderr, "failed to open %s for physical memory: %s\n",
+ device_name, strerror(errno));
exit(EXIT_FAIL_NONSTARTER);
}
buf = (void volatile *) mmap(0, wantbytes, PROT_READ | PROT_WRITE,
MAP_SHARED | MAP_LOCKED, memfd,
physaddrbase);
if (buf == MAP_FAILED) {
- perror("failed to mmap /dev/mem for physical memory");
+ fprintf(stderr, "failed to mmap %s for physical memory: %s\n",
+ device_name, strerror(errno));
exit(EXIT_FAIL_NONSTARTER);
}
@@ -332,6 +379,12 @@
}
for (i=0;;i++) {
if (!tests[i].name) break;
+ /* If using a custom testmask, only run this test if the
+ bit corresponding to this test was set by the user.
+ */
+ if (testmask && (!((1 << i) & testmask))) {
+ continue;
+ }
printf(" %-20s: ", tests[i].name);
if (!tests[i].fp(bufa, bufb, count)) {
printf("ok\n");
|
[-]
[+]
|
Changed |
memtester-4.3.0.tar.bz2/memtester.h
^
|
@@ -4,7 +4,7 @@
* Version 2 by Charles Cazabon <charlesc-memtester@pyropus.ca>
* Version 3 not publicly released.
* Version 4 rewrite:
- * Copyright (C) 2004-2010 Charles Cazabon <charlesc-memtester@pyropus.ca>
+ * Copyright (C) 2004-2012 Charles Cazabon <charlesc-memtester@pyropus.ca>
* Licensed under the terms of the GNU General Public License version 2 (only).
* See the file COPYING for details.
*
|
[-]
[+]
|
Changed |
memtester-4.3.0.tar.bz2/sizes.h
^
|
@@ -4,7 +4,7 @@
* Version 2 by Charles Cazabon <charlesc-memtester@pyropus.ca>
* Version 3 not publicly released.
* Version 4 rewrite:
- * Copyright (C) 2004-2010 Charles Cazabon <charlesc-memtester@pyropus.ca>
+ * Copyright (C) 2004-2012 Charles Cazabon <charlesc-memtester@pyropus.ca>
* Licensed under the terms of the GNU General Public License version 2 (only).
* See the file COPYING for details.
*
|
[-]
[+]
|
Changed |
memtester-4.3.0.tar.bz2/tests.c
^
|
@@ -4,7 +4,7 @@
* Version 2 by Charles Cazabon <charlesc-memtester@pyropus.ca>
* Version 3 not publicly released.
* Version 4 rewrite:
- * Copyright (C) 2004-2010 Charles Cazabon <charlesc-memtester@pyropus.ca>
+ * Copyright (C) 2004-2012 Charles Cazabon <charlesc-memtester@pyropus.ca>
* Licensed under the terms of the GNU General Public License version 2 (only).
* See the file COPYING for details.
*
|
[-]
[+]
|
Changed |
memtester-4.3.0.tar.bz2/tests.h
^
|
@@ -4,7 +4,7 @@
* Version 2 by Charles Cazabon <charlesc-memtester@pyropus.ca>
* Version 3 not publicly released.
* Version 4 rewrite:
- * Copyright (C) 2004-2010 Charles Cazabon <charlesc-memtester@pyropus.ca>
+ * Copyright (C) 2004-2012 Charles Cazabon <charlesc-memtester@pyropus.ca>
* Licensed under the terms of the GNU General Public License version 2 (only).
* See the file COPYING for details.
*
|