Linux下 内存测试工具memtester

下载地址:http://pyropus.ca/software/memtester/  有源码安装包、deb包、rpm包等。

源码已经编译好,在linux下只要make一下就好了。

 笔者要测试的是目标板的内存,所以要交叉编译,目标板为mips架构,所以要改变 Makefile

     解压之后,目录下有这样两个文件:conf-ccconf-ld

    打开conf-cc,第一行:cc -O2 -DPOSIX -D_POSIX_C_SOURCE=200809L -D_FILE_OFFSET_BITS=64 -DTEST_NARROW_WRITES -c
   改为:mipsel-linux-gcc -O2 -DPOSIX -D_POSIX_C_SOURCE=200809L -D_FILE_OFFSET_BITS=64 -DTEST_NARROW_WRITES -c

   同理,改变conf-ld

      然后,直接make,就会生成memtester,把这个下到目标板就可以了。 

 

使用方法:

Usage: memtester [-p physaddrbase] [B|K|M|G] [loops]
如:
memtester 28G 3 #测试28G的内存3次。

因为系统运行和本工具运行都需要内存,所以不能把所有的内存都测试到。可以先用free 命令查看系统剩余多少内存空间再测试。

高级点的可以用-p参数从内存地址开始测试。

memtester version 4.2.0 (64-bit)
Copyright (C) 2010 Charles Cazabon.
Licensed under the GNU General Public License version 2 (only).

pagesize is 4096
pagesizemask is 0xfffffffffffff000
want 28672MB (30064771072 bytes)
got  28672MB (30064771072 bytes), trying mlock ...locked.
Loop 1/3:
  Stuck Address       : testing   0memtester version 4.2.0 (64-bit)
Copyright (C) 2010 Charles Cazabon.
Licensed under the GNU General Public License version 2 (only).
 

pagesize is 4096
pagesizemask is 0xfffffffffffff000
want 28672MB (30064771072 bytes)
got  28672MB (30064771072 bytes), trying mlock ...locked.
Loop 1/3:
  Stuck Address       : ok        
  Random Value        : ok
  Compare XOR         : ok
  Compare SUB         : ok
  Compare MUL         : ok
  Compare DIV         : ok
  Compare OR          : ok
  Compare AND         : ok
  Sequential Increment: ok
  Solid Bits          : ok        
  Block Sequential    : ok        
  Checkerboard        : ok        
  Bit Spread          : ok        
  Bit Flip            : ok        
  Walking Ones        : ok        
  Walking Zeroes      : ok        
  8-bit Writes        : ok
  16-bit Writes       : ok


结果全部为OK则内存正常。

对于某些不需要的测试项目可以通过修改memtester.c文件,注释掉某些内容再重新make一下便可。如下:


struct test tests[] = {
    { "Random Value", test_random_value },
    { "Compare XOR", test_xor_comparison },
    { "Compare SUB", test_sub_comparison },
    { "Compare MUL", test_mul_comparison },
    { "Compare DIV",test_div_comparison },
    { "Compare OR", test_or_comparison },
    { "Compare AND", test_and_comparison },
 
 
    { NULL, NULL }
};

 

你可能感兴趣的:(Linux,测试)