mirror of
https://github.com/lakinduakash/linux-wifi-hotspot.git
synced 2024-11-24 05:00:14 +00:00
Add unit test
This commit is contained in:
parent
c9d2016a07
commit
53ea4b2e1d
6
Makefile
6
Makefile
@ -8,6 +8,10 @@ install:
|
||||
@echo "Installing..."
|
||||
cd src && $(MAKE) install
|
||||
|
||||
test:
|
||||
@echo "Testing..."
|
||||
cd test && $(MAKE)
|
||||
|
||||
install-cli-only:
|
||||
@echo "Installing command line interface only..."
|
||||
cd src/scripts && $(MAKE) install
|
||||
@ -19,7 +23,7 @@ uninstall:
|
||||
clean-old:
|
||||
cd src && $(MAKE) clean-old
|
||||
|
||||
.PHONY: clean
|
||||
.PHONY: clean test
|
||||
|
||||
clean:
|
||||
cd src && $(MAKE) clean
|
||||
|
37
test/Makefile
Normal file
37
test/Makefile
Normal file
@ -0,0 +1,37 @@
|
||||
CC=gcc
|
||||
PKGCONFIG = $(shell which pkg-config)
|
||||
|
||||
CFLAGS=`pkg-config --cflags gtk+-3.0` -I./../src/ui
|
||||
|
||||
LIBS=`pkg-config --libs gtk+-3.0 --libs x11` -lstdc++ -lpng -lqrencode
|
||||
|
||||
|
||||
ODIR=./../build
|
||||
|
||||
# Determine this makefile's path.
|
||||
# Be sure to place this BEFORE `include` directives, if any.
|
||||
THIS_FILE := $(lastword $(MAKEFILE_LIST))
|
||||
|
||||
_OBJ = util.o test_util.o
|
||||
OBJ = $(patsubst %,$(ODIR)/%,$(_OBJ))
|
||||
|
||||
|
||||
.PHONY: clean
|
||||
|
||||
all: $(OBJ) test
|
||||
|
||||
|
||||
$(ODIR)/util.o: ../src/ui/util.c
|
||||
$(CC) -c $? -o $@ $(CFLAGS)
|
||||
|
||||
$(ODIR)/test_util.o: test_util.c
|
||||
$(CC) -c $? -o $@ $(CFLAGS)
|
||||
|
||||
test: $(OBJ)
|
||||
$(CC) -o $(ODIR)/test $^
|
||||
@$(ODIR)/test
|
||||
|
||||
clean:
|
||||
rm -f $(OBJ)
|
||||
rm -f $(ODIR)/test
|
||||
|
14
test/test_util.c
Normal file
14
test/test_util.c
Normal file
@ -0,0 +1,14 @@
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <util.h>
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
|
||||
assert(0 == isValidIPaddress("192.12.23.123"));
|
||||
assert(0 == isValidIPaddress("255.255.255.255"));
|
||||
assert(-1 == isValidIPaddress("255.255.255.256"));
|
||||
assert(-1 == isValidIPaddress("255.255.255.2551"));
|
||||
assert(-1 == isValidIPaddress("192.168.12"));
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user