Skip to content

Commit

Permalink
Fix examples/hello test round#2
Browse files Browse the repository at this point in the history
I forgot to check whether the result is `IMAGE_SYNTH_SUCCESS`.
  • Loading branch information
J.W committed Feb 23, 2022
1 parent 1f6cda5 commit 18ea722
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
26 changes: 14 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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: 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 18ea722

Please sign in to comment.