Changeset 1139 in MondoRescue for branches/stable/mondo/src/test


Ignore:
Timestamp:
Feb 11, 2007, 7:04:12 PM (17 years ago)
Author:
Bruno Cornec
Message:

memory tests improvements
useless code removed from libmondo-fork.c
more merges for libmondo-archive.c

Location:
branches/stable/mondo/src/test
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/stable/mondo/src/test/mktest

    r1104 r1139  
    66#
    77
    8 lib="../lib/mr_conf.c ../lib/mr_msg.c ../lib/mr_err.c ../lib/mr_mem.c"
    9 OPT="-Wall -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_REENTRANT -Wstrict-prototypes -Wshadow -funsigned-char -Wunused -Winit-self -Wcast-align -fno-strict-aliasing -O2 -g -I../common -I../include"
     8lib="../lib/mr_conf.c ../lib/mr_msg.c ../lib/mr_err.c ../lib/mr_mem.c ../lib/mr_str.c ../lib/mr_file.c"
     9OPT="-Wall -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_REENTRANT -Wstrict-prototypes -Wshadow -funsigned-char -Wunused -Wcast-align -fno-strict-aliasing -O2 -g -I../common -I../include"
    1010
    11 echo "Generating test-msg"
    12 gcc $OPT test-msg.c $lib -o test-msg
    13 echo "Generating test-string"
    14 gcc $OPT test-string.c ../lib/mr_str.c $lib -o test-string
    15 echo "Generating test-conf"
    16 gcc $OPT test-conf.c $lib -o test-conf
    17 echo "Generating test-mem"
    18 gcc $OPT test-mem.c $lib -o test-mem
     11prg="test-conf test-string test-msg test-mem"
     12
     13for i in $prg ; do
     14    echo "Generating $i"
     15    gcc $OPT $i.c $lib -o $i
     16done
    1917
    2018echo "Testing against previous run"
    21 for f in test-conf test-string test-msg test-mem; do
     19for f in $prg ; do
    2220    chmod 755 $f
    2321    ./$f > /tmp/$f.res
     
    2826        echo "$f test OK"
    2927    fi
     28done
     29for f in $prg ; do
    3030    valgrind -q --error-exitcode=1 --leak-check=yes ./$f 2>&1 > /tmp/valgrind-$f.res
    3131    if [ $? -ne 0 ]; then
  • branches/stable/mondo/src/test/test-mem.c

    r1105 r1139  
    1 #include <mr_mem.h>
    21#include <stdio.h>
    32#include <stdlib.h>
    43#include <assert.h>
    54
     5#include "mr_mem.h"
     6#include "mr_file.h"
     7
    68void is_null(const char* str)
    79{
    8   if (str == NULL)
    9         printf("pointer is null\n");
    10   else
    11         printf("pointer is NOT null\n");
     10    if (str == NULL)
     11          printf("pointer is null\n");
     12    else
     13          printf("pointer is NOT null\n");
    1214}
    1315
    1416int main(void)
    1517{
    16   char* str = NULL;
     18    char* str = NULL;
     19    FILE *fd = NULL;
     20    size_t n = 0;
    1721
    18   printf("*** Test with mr_free\n");
    19   str = mr_malloc(10);
    20   is_null(str);
    21   mr_free(str);
    22   is_null(str);
     22    printf("*** Test with mr_malloc/mr_free\n");
     23    str = mr_malloc(10);
     24    is_null(str);
     25    mr_free(str);
     26    is_null(str);
    2327
    24   printf("*** Test with NULL\n");
    25   str = NULL;
    26   is_null(str);
    27   mr_free(str);
    28   is_null(str);
     28    printf("*** Test with mr_asprintf/mr_free\n");
     29    mr_asprintf(&str,"Chain %s","of trust");
     30    printf("Result: %s\n",str);
     31    mr_free(str);
    2932
    30   return 0;
     33    printf("*** Test with mr_getline/mr_free\n");
     34    fd = mr_fopen("/etc/passwd","r");
     35    mr_getline(&str,&n,fd);
     36    printf("1st Result: %s",str);
     37    mr_getline(&str,&n,fd);
     38    printf("2nd Result: %s",str);
     39    mr_free(str);
     40
     41    printf("*** Test with NULL\n");
     42    str = NULL;
     43    is_null(str);
     44    mr_free(str);
     45    is_null(str);
     46
     47    return 0;
    3148}
    3249
Note: See TracChangeset for help on using the changeset viewer.