First unit tests for scheduler

This commit is contained in:
Adrien Bourmault 2021-06-14 20:22:11 +02:00
parent 6c7a46d3cd
commit 0319676d7e
No known key found for this signature in database
GPG Key ID: 6EB408FE0ACEC664
6 changed files with 31 additions and 74 deletions

View File

@ -27,7 +27,15 @@ DEBDIR=debian
OBJ=$(BINDIR)/scheduler.o $(BINDIR)/server.o $(BINDIR)/localworker.o $(BINDIR)/main.o
.DEFAULT_GOAL:= all
.PHONY: all clean deb
.PHONY: all clean deb tests install run
# ---- Tests enumeration ----------------------------------------------------- #
TEST_SCHEDULER=$(BINDIR)/tests/scheduler
TESTS=$(TEST_SCHEDULER)
$(BINDIR)/tests/scheduler: $(SRCDIR)/tests/scheduler.c
@echo "Compiling $<"
@$(CC) $(CCINCLUDES) $(CCOPTS) $(CCFLAGS) $(LDFLAGS) -o $@ $<
# ---- General recipes ------------------------------------------------------- #
@ -43,9 +51,11 @@ $(BINDIR)/gem-graph-server: $(OBJ)
# ---- Misc recipes ---------------------------------------------------------- #
clean:
rm -rf $(SRCDIR)/*.o $(BINDIR)/* *.deb
-rm -f $(SRCDIR)/*.o $(BINDIR)/* $(BINDIR)/tests/* *.deb
all: $(DYNLIBS) $(BINDIR)/gem-graph-server
all: $(BINDIR)/gem-graph-server
tests: $(TESTS)
# ---- Build debian package -------------------------------------------------- #
$(BINDIR)/gem-graph-server.deb: all
@ -63,6 +73,8 @@ install:
echo "Installing is not supported"
# ---- Builder uses this target to run your application ---------------------- #
run:
run: all
bin/gem-graph-server
run-tests: tests
bin/tests/scheduler

View File

@ -1,2 +1,13 @@
# gem-graph-server
Build & execute the program:
```
make
make run
```
Build & execute tests
```
make tests
make run-tests
```

View File

@ -50,6 +50,7 @@ static inline void centerAssign(Center_t *center, int x, int y, int z)
static inline Center_t *centerAdd(Center_t *anyCenter, Center_t *newCenter)
{
if (!newCenter) return NULL;
if (anyCenter->next) {
anyCenter->next->prev = newCenter;
}
@ -62,10 +63,9 @@ static inline Center_t *centerAdd(Center_t *anyCenter, Center_t *newCenter)
static inline void centerRemove(Center_t *oldCenter)
{
oldCenter->prev->next = oldCenter->next;
oldCenter->next->prev = oldCenter->prev;
free(oldCenter);
if (!oldCenter) return;
if (oldCenter->prev) oldCenter->prev->next = oldCenter->next;
if (oldCenter->next) oldCenter->next->prev = oldCenter->prev;
}
// -------------------------------------------------------------------------- //

View File

@ -1,22 +0,0 @@
//=-------------------------------------------------------------------------=//
// Local worker tests //
// //
// Copyright © 2021 The Gem-graph Project //
// //
// This file is part of gem-graph. //
// //
// This program is free software: you can redistribute it and/or modify //
// it under the terms of the GNU Affero General Public License as //
// published by the Free Software Foundation, either version 3 of the //
// License, or (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU Affero General Public License for more details. //
// //
// You should have received a copy of the GNU Affero General Public License //
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
//=-------------------------------------------------------------------------=//
#include "../localworker.c"

View File

@ -1,22 +0,0 @@
//=-------------------------------------------------------------------------=//
// Scheduler tests //
// //
// Copyright © 2021 The Gem-graph Project //
// //
// This file is part of gem-graph. //
// //
// This program is free software: you can redistribute it and/or modify //
// it under the terms of the GNU Affero General Public License as //
// published by the Free Software Foundation, either version 3 of the //
// License, or (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU Affero General Public License for more details. //
// //
// You should have received a copy of the GNU Affero General Public License //
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
//=-------------------------------------------------------------------------=//
#include "../scheduler.c"

View File

@ -1,22 +0,0 @@
//=-------------------------------------------------------------------------=//
// Server tests //
// //
// Copyright © 2021 The Gem-graph Project //
// //
// This file is part of gem-graph. //
// //
// This program is free software: you can redistribute it and/or modify //
// it under the terms of the GNU Affero General Public License as //
// published by the Free Software Foundation, either version 3 of the //
// License, or (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU Affero General Public License for more details. //
// //
// You should have received a copy of the GNU Affero General Public License //
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
//=-------------------------------------------------------------------------=//
#include "../server.c"