Changeset 1065


Ignore:
Timestamp:
Jan 23, 2007, 3:48:48 AM (12 years ago)
Author:
bruno
Message:

More tests in
mr_msg function doesn't cascade to _mr_msg anymore, as it doesn't seem to work correctly with multiple varargs entries (I've not found how to do it correctly, so I give up for the moment)
lib code pass valgrind without issue.

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

Legend:

Unmodified
Added
Removed
  • branches/stable/mondo/src/lib/mr_msg.c

    r1064 r1065  
    2020static char *mr_logfile = NULL;
    2121
     22/*
     23 * This function is in the lowest part of the tree
     24 * It should not depend on any other function of the mr lib
     25 */
     26
    2227/* Cleanup function for messages */
    2328void mr_msg_close(void) {
    2429    free(mr_logfile);
    2530    mr_logfile = NULL;
     31    mr_loglevel = 0;
    2632}
    2733
     
    4753 * but through other functions
    4854 */
    49 void _mr_msg(int debug, const char *file, const char *function, int line, const char *fmt, ...) {
     55void mr_msg(int debug, const char *fmt, ...) {
    5056
    5157    int i = 0;
     
    6369            return;
    6470        }
    65         va_start(args,fmt);
    6671
    6772        // add 2 spaces to distinguish log levels
     
    6974            for (i = 1; i < debug; i++)
    7075                fprintf(fout, "  ");
    71             fprintf(fout, "%s->%s#%d: ", file, function, line);
     76            fprintf(fout, "%s->%s#%d: ", __FILE__, __FUNCTION__, __LINE__);
    7277        }
     78        va_start(args,fmt);
    7379        if (vfprintf(fout, fmt, args) < 0) {
    7480            fprintf(stderr,"Unable to print to %s\n",mr_logfile);
    7581        }
     82        va_end(args);
    7683
    77         fprintf(fout, "\n");
    7884        if ((res = fclose(fout)) != 0) {
    7985            fprintf(stderr,"Unable to close %s\n",mr_logfile);
    8086        }
    81         va_end(args);
    8287    }
    8388}
    84 
    85 void mr_msg(int level, const char *fmt, ...) {
    86 
    87     va_list args;
    88 
    89     va_start(args,fmt);
    90     _mr_msg(level, __FILE__, __FUNCTION__, __LINE__, fmt, args);
    91     va_end(args);
    92 }
  • branches/stable/mondo/src/test/mktest

    r1064 r1065  
    1616gcc $OPT test-conf.c $lib -o test-conf
    1717
     18echo "Testing against previous run"
    1819for f in test-conf test-string test-msg; do
    1920    chmod 755 $f
     
    2324        echo "$f test KO !!"
    2425    fi
     26    valgrind -q --error-exitcode=1 --leak-check=yes ./$f 2>&1 > /tmp/valgrind-$f.res
     27    if [ $? -ne 0 ]; then
     28        echo "valgrind $f test KO !!"
     29    fi
    2530done
Note: See TracChangeset for help on using the changeset viewer.