Skip to content

Commit

Permalink
Added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wbourne0 committed Jun 1, 2020
1 parent 337f4bf commit 8ac55fc
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 19 deletions.
27 changes: 14 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ OPUSFILE_LIB_DIR="$(CWD)/opus/lib/opusfile"
OGG_LIB_DIR="$(CWD)/opus/lib/ogg"
URL_LIB_DIR="$(CWD)/opus/lib/url"
LIBSAMPLERATE_FILES=./gosamplerate/lib/libsamplerate.a ./gosamplerate/lib/samplerate.h
OPUS_FILES=./opus/lib/opus.h ./opus/lib/opus_types.h ./opus/lib/libopus.a ./opus/lib/opus_defines.h ./opus/lib/opus_projection.h ./opus/lib/opus_multistream.h ./opus/lib/opus/opus.h ./opus/lib/opus/opus_types.h ./opus/lib/opus/opus_defines.h ./opus/lib/opus/opus_projection.h ./opus/lib/opus/opus_multistream.h ./opus/lib/ogg/libogg.a ./opus/lib/ogg/ogg/os_types.h ./opus/lib/ogg/ogg/ogg.h ./opus/lib/ogg/ogg/config_types.h ./opus/lib/opusfile/libopusurl.a ./opus/lib/opusfile/libopusfile.a ./opus/lib/opusfile/opus/opusfile.h

.PHONY: build
build: $(LIBSAMPLERATE_FILES) ./opus/lib ## Build the required c libraries. This can take a while.
build: $(LIBSAMPLERATE_FILES) $(OPUS_FILES) ## Build the required c libraries. This can take a while.

$(LIBSAMPLERATE_FILES):
@echo "Installing libsamplerate"
@./scripts/install_libsamplerate

./opus/lib: ## Build and install opusfile and its dependancies
$(OPUS_FILES): ## Build and install opusfile and its dependancies
@echo "Installing libopus and libopusfile"
@./scripts/install_opus

Expand All @@ -23,7 +24,11 @@ rebuild: clean build ## This may take a while.

.PHONY: rebuild-all
rebuild-all: clean-all build ## This rebuilds EVERYTHING, and can take quite a while.
cd /tmp && rm -r opus-1.3.1 \


.PHONY: clean-all
clean-all: clean
-@cd /tmp && rm -r opus-1.3.1 \
opusfile-0.9 \
opusfile.tar.gz \
opus.tar.gz \
Expand All @@ -32,20 +37,16 @@ rebuild-all: clean-all build ## This rebuilds EVERYTHING, and can take quite a w
libsamplerate-0.1.9 \
libsamplerate.tar.gz \
openssl-1.1.1g \
openssl.tar.gz



.PHONY: clean-all
clean-all:
rm -r
openssl.tar.gz >> /dev/null 2>&1

.PHONY: clean
clean: ## Remove c libraries
@-rm -r ./opus/lib ./gosamplerate/lib
-@rm -r ./opus/lib ./gosamplerate/lib >> /dev/null 2>&1

test: ## As this is just intended to be the go bindings bundled with static executables this just tests if they're static.
@./scripts/test


audio: ./opus/lib $(LIBSAMPLERATE_FILES) ./* ./*/*
go build audio.go

.PHONY: check
check: main
Expand Down
Binary file added gosamplerate/gosamplerate
Binary file not shown.
2 changes: 1 addition & 1 deletion opus/decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

/*
#cgo LDFLAGS: -static -L./lib -lopus -lm
#cgo LDFLAGS: -L./lib -lopus -lm
#cgo CFLAGS: -I./lib/opus
#include <opus.h>
Expand Down
4 changes: 2 additions & 2 deletions opus/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
)

/*
#cgo LDFLAGS: -static -L./lib/opusfile -L./lib/ogg -L./lib -lopusfile -logg -lopus -lm
#cgo CFLAGS: -I./lib/opusfile/opus -I./lib/ogg -I./lib/opus
#cgo LDFLAGS: -L./lib -L./lib/ogg -L./lib/opusfile -lopusfile -lm -logg -lopus -lm
#cgo CFLAGS: -I./lib/opus -I./lib/ogg -I./lib/opusfile/opus
#include <ogg/ogg.h>
#include <opus.h>
Expand Down
Binary file added opus/opus
Binary file not shown.
2 changes: 1 addition & 1 deletion opus/opus.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
package opus

/*
#cgo LDFLAGS: -static -L./lib -lopus -lm
#cgo LDFLAGS: -L./lib -lopus -lm
#cgo CFLAGS: -I./lib/opus
#include <opus.h>
Expand Down
4 changes: 2 additions & 2 deletions opus/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
)

/*
#cgo LDFLAGS: -static -L./lib/opusfile -L./lib/ogg -L./lib -lopusfile -logg -lopus -lm
#cgo CFLAGS: -I./lib/opusfile/opus -I./lib/ogg -I./lib/opus
#cgo LDFLAGS: -L./lib -L./lib/ogg -L./lib/opusfile -lopusfile -lm -logg -lopus -lm
#cgo CFLAGS: -I./lib/opus -I./lib/ogg -I./lib/opusfile/opus
#include <opusfile.h>
#include <string.h>
Expand Down
33 changes: 33 additions & 0 deletions scripts/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

EXPECTED=" not a dynamic executable"

test() {
got=$1
expected=$2
name=$3
if [ "$got" = "$expected" ]; then
echo "$name got a static executable as expected"
else
echo "Expected to get"
echo "$EXPECTED"
echo "But recieved"
echo "$got"
echo "$got"
echo "$expected"
echo "$EXPECTED"
exit
fi
}

echo "Testing opus"
cd opus && go build -o opus
cd ..

test "$(ldd opus/opus)" "$EXPECTED" opus
cd gosamplerate && go build -o gosamplerate
cd ..

test "$(ldd gosamplerate/gosamplerate)" "$EXPECTED" gosamplerate

echo "All tests passed"

0 comments on commit 8ac55fc

Please sign in to comment.