Skip to content

Commit

Permalink
Merge pull request #3 from jakwings/test
Browse files Browse the repository at this point in the history
Fix examples/hello test round#2
  • Loading branch information
61315 committed Feb 23, 2022
2 parents 1f6cda5 + a3ec672 commit 89fb3b8
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 15 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# https://github.com/actions/checkout
# https://docs.github.com/actions/using-workflows

name: 'GitHub Continuous Integration'

on: [push, pull_request]

jobs:
macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: brew install pkg-config sdl2
- name: Build & Test
run: make all test

ubuntu:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: sudo apt-get install pkg-config libsdl2-dev
- name: Build & Test
run: make all test
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.vscode
**/build
**/lib
**/out
**/output
28 changes: 15 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
CC = clang -std=c99
CPPFLAGS = -MMD -MP -DSYNTH_LIB_ALONE
CFLAGS = -Wall -Wextra -pedantic -O3
LDFLAGS =
LDFLAGS = -lm
LDLIBS =
# PREFIX = /usr/local

Expand All @@ -20,6 +20,7 @@ INC_FLAGS := $(addprefix -I,$(INC_DIRS))

STATIC_LIB := $(LIB_DIR)/libresynthesizer.a

ASSET_DIR := assets
EXAMPLE_DIR := examples
EXAMPLES := $(EXAMPLE_DIR)/hello $(EXAMPLE_DIR)/ppm $(EXAMPLE_DIR)/painter

Expand All @@ -41,33 +42,33 @@ $(BUILD_DIR)/%.o: %.c
$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@

# Build the example executables.
$(EXAMPLE_DIR)/hello: examples/hello.c $(STATIC_LIB)
$(EXAMPLE_DIR)/hello: $(EXAMPLE_DIR)/hello.c $(STATIC_LIB)
@echo "\033[1;92mBuilding $@\033[0m"
mkdir -p $(dir $@)
$(CC) $(CFLAGS) -o $@ examples/hello.c $(LDFLAGS) $(INC_FLAGS) $(STATIC_LIB)
$(CC) $(CFLAGS) -o $@ $(EXAMPLE_DIR)/hello.c $(LDFLAGS) $(INC_FLAGS) $(STATIC_LIB)

$(EXAMPLE_DIR)/ppm: examples/ppm.c $(STATIC_LIB)
$(EXAMPLE_DIR)/ppm: $(EXAMPLE_DIR)/ppm.c $(STATIC_LIB)
@echo "\033[1;92mBuilding $@\033[0m"
mkdir -p $(dir $@)
$(CC) $(CFLAGS) -o $@ examples/ppm.c $(LDFLAGS) $(INC_FLAGS) $(STATIC_LIB)
$(CC) $(CFLAGS) -o $@ $(EXAMPLE_DIR)/ppm.c $(LDFLAGS) $(INC_FLAGS) $(STATIC_LIB)

$(EXAMPLE_DIR)/painter: examples/painter.c $(STATIC_LIB)
$(EXAMPLE_DIR)/painter: $(EXAMPLE_DIR)/painter.c $(STATIC_LIB)
@echo "\033[1;92mBuilding $@\033[0m"
mkdir -p $(dir $@)
$(CC) $(CFLAGS) -o $@ examples/painter.c $(LDFLAGS) $(INC_FLAGS) $(STATIC_LIB) $(shell pkg-config --cflags --libs sdl2)
$(CC) $(CFLAGS) -o $@ $(EXAMPLE_DIR)/painter.c $(LDFLAGS) $(INC_FLAGS) $(STATIC_LIB) $(shell pkg-config --cflags --libs sdl2)

# Run the executable(ppm) against the sample images with varying parameters.
fuzz: $(EXAMPLE_DIR)/ppm
@echo "\033[1;92mFuzzing...\033[0m"
mkdir -p out
mkdir -p $(EXAMPLE_DIR)/output
@for number in 0 1 2 3 4 ; do \
for context in 0 1 2 3 4 5 6 7 8 ; do \
for neighbors in 9 64 ; do \
for probes in 64 256 ; do \
./examples/ppm \
assets/source00$${number}.ppm \
assets/mask00$${number}.ppm \
out/result00$${number}"_"$${context}"_"$${neighbors}"_"$${probes}.ppm \
$(EXAMPLE_DIR)/ppm \
$(ASSET_DIR)/source00$${number}.ppm \
$(ASSET_DIR)/mask00$${number}.ppm \
$(EXAMPLE_DIR)/output/result00$${number}"_"$${context}"_"$${neighbors}"_"$${probes}.ppm \
$${context} $${neighbors} $${probes} ; \
done \
done \
Expand All @@ -76,10 +77,11 @@ fuzz: $(EXAMPLE_DIR)/ppm

test: $(EXAMPLE_DIR)/hello
@echo "\033[1;92mTesting...\033[0m"
@if ./examples/hello; then \
@if $(EXAMPLE_DIR)/hello; then \
echo "\033[1;92mTest Passed!\033[0m"; \
else \
echo "\033[1;91mTest Failed!\033[0m"; \
exit 1; \
fi

.PHONY: clean test all
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[![](https://github.com/61315/resynthesizer/actions/workflows/test.yml/badge.svg)](https://github.com/61315/resynthesizer/actions/workflows/test.yml)

# resynthesizer

WIP
Expand Down
2 changes: 1 addition & 1 deletion examples/hello.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,5 @@ int main()

puts(enums[error]);

return EXIT_SUCCESS;
return error == IMAGE_SYNTH_SUCCESS ? EXIT_SUCCESS : EXIT_FAILURE;
}

0 comments on commit 89fb3b8

Please sign in to comment.