RaspberrPi project source code
guowenxue
2024-05-27 cfdcbd734b4ede4933c87cbe4c44f8aa855b910d
add test example code in booster
2 files added
109 ■■■■■ changed files
project/booster/test/makefile 64 ●●●●● patch | view | raw | blame | history
project/booster/test/test_logger.c 45 ●●●●● patch | view | raw | blame | history
project/booster/test/makefile
New file
@@ -0,0 +1,64 @@
#*********************************************************************************
#      Copyright:  (C) 2022 Guo Wenxue
#                  All rights reserved.
#
#       Filename:  Makefile
#    Description:  This Makefile used to compile all the C source code file in current
#                  folder to respective excutable binary files.
#
#        Version:  1.0.0(03/15/2022~)
#                  Author:  Guo Wenxue <guowenxue@gmail.com>
#      ChangeLog:  1, Release initial version on "03/15/2022 01:29:33 PM"
#
#********************************************************************************/
PWD=$(shell pwd)
LIB_PATH=$(shell dirname ${PWD})
LIB_NAME=$(shell basename ${LIB_PATH})
INSTPATH=/tftp
#ARCH ?= i386
#ARCH?=arm926t
ARCH?=arm920t
#LINK_MODE=STATIC
MODE=PRODUCTION
DEBUG=1
INSTPATH=/tftp
#CROSS_COMPILE=aarch64-linux-gnu-
export CC=${CROSS_COMPILE}gcc
export CXX=${CROSS_COMPILE}g++
export AR=${CROSS_COMPILE}ar
export AS=${CROSS_COMPILE}as
export RANLIB=${CROSS_COMPILE}ranlib
export STRIP=${CROSS_COMPILE}strip
SRCS = $(wildcard ${VPATH}/*.c)
OBJS = $(patsubst %.c,%.o,$(SRCS))
SRCFILES = $(wildcard *.c)
BINARIES=$(SRCFILES:%.c=%)
CFLAGS+=-I${LIB_PATH}
LDFLAGS+=-L${LIB_PATH} -l${LIB_NAME}
all: binaries install
binaries:  ${BINARIES}
%:  %.c
    $(CC) $(CFLAGS) -o $@ $< $(LDFLAGS)
install:
    cp $(BINARIES) ${INSTPATH}
clean:
    @rm -f *.o *.lo $(BINARIES)
distclean: clean
    @rm -f  tags cscope*
.PHONY: clean entry
project/booster/test/test_logger.c
New file
@@ -0,0 +1,45 @@
/*********************************************************************************
 *      Copyright:  (C) 2012 Guo Wenxue <guowenxue@gmail.com>
 *                  All rights reserved.
 *
 *       Filename:  test_logger.c
 *    Description:  This is the linux logger system test code.
 *
 *        Version:  1.0.0(08/08/2012~)
 *         Author:  Guo Wenxue <guowenxue@gmail.com>
 *      ChangeLog:  1, Release initial version on "08/08/2012 06:51:40 PM"
 *
 ********************************************************************************/
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <libgen.h>
#include "logger.h"
int main (int argc, char **argv)
{
    char    buf[256];
    int     i;
    for(i=0; i<sizeof(buf); i++)
        buf[i] = i;
#if 0
    log_open("console", LOG_LEVEL_DEBUG, 0, LOG_LOCK_DISABLE);
#else
    log_open("test.log", LOG_LEVEL_DEBUG, 10, LOG_LOCK_DISABLE);
#endif
    log_error("This is a errorr message\n");
    log_warn("This is a warnning message\n");
    log_info("This is a informat message\n");
    log_debug("This is a debug message\n");
    log_trace("This is a trace message\n");
    log_dump(LOG_LEVEL_DEBUG, "Hex dump buffer content:", buf, sizeof(buf));
    log_close();
    return 0;
}