Initial testing support

Added the ability to compile a subset of functions in to a test
executable for Linux. To be used in the future for testing.

Removed unnecessary includes.

Tested working by compiling test executable for GNU/Linux and for the
3DS. The 3dsx was tested in citra.

Signed-off-by: Mahyar Koshkouei <mk@deltabeard.com>
This commit is contained in:
Mahyar Koshkouei
2017-08-14 21:50:54 +01:00
parent 9a7d3683b9
commit 11d7bede77
10 changed files with 130 additions and 6 deletions

63
Makefile.linux Normal file
View File

@@ -0,0 +1,63 @@
# Makefile to produce test build of ctrmus for Linux
#
# make -f Makefile.linux
ifeq ($(OS),Windows_NT)
HOST_OS := windows
ifeq ($(PROCESSOR_ARCHITECTURE),AMD64)
HOST_ARCH := x86_64
else
HOST_ARCH := i686
endif
else
UNAME_M := $(shell uname -m)
ifeq ($(UNAME_M),$(filter $(UNAME_M),x86_64 amd64))
HOST_ARCH := x86_64
else ifeq ($(UNAME_M),$(filter $(UNAME_M),i386 i686))
HOST_ARCH := i686
else
$(error "Unsupported host architecture.")
endif
endif
IDIR =./source
CC=gcc
CFLAGS=-I./include/
LIBS=-lmpg123 -lvorbisidec -lopusfile -lopus -logg -lm
ODIR=./build/$(HOST_ARCH)
SDIR=./source
_DEPS = all.h \
flac.h \
mp3.h \
opus.h \
vorbis.h \
wav.h
DEPS = $(patsubst %,$(IDIR)/%,$(_DEPS))
_OBJ = flac.o \
mp3.o \
opus.o \
test.o \
vorbis.o \
wav.o
OBJ = $(patsubst %,$(ODIR)/%,$(_OBJ))
all: directory test
directory:
mkdir -p $(ODIR)
$(ODIR)/%.o: $(SDIR)/%.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS)
test: $(OBJ)
gcc -o $@ $^ $(CFLAGS) $(LIBS)
.PHONY: clean directory
clean:
rm -f $(ODIR)/*.o *~ core $(INCDIR)/*~

View File

@@ -1,5 +1,3 @@
#include <3ds.h>
#define DR_FLAC_IMPLEMENTATION #define DR_FLAC_IMPLEMENTATION
#include <./dr_libs/dr_flac.h> #include <./dr_libs/dr_flac.h>

View File

@@ -1,4 +1,3 @@
#include <3ds.h>
#include <mpg123.h> #include <mpg123.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>

View File

@@ -1,3 +1,4 @@
#include <stdint.h>
#include "playback.h" #include "playback.h"
/** /**

View File

@@ -1,4 +1,3 @@
#include <3ds.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>

View File

@@ -1,3 +1,5 @@
#include <stdbool.h>
#ifndef ctrmus_playback_h #ifndef ctrmus_playback_h
#define ctrmus_playback_h #define ctrmus_playback_h

63
source/test.c Normal file
View File

@@ -0,0 +1,63 @@
#if defined __gnu_linux__
#include <stdint.h>
#include <stdio.h>
#include "flac.h"
#include "mp3.h"
#include "opus.h"
#include "playback.h"
#include "vorbis.h"
#include "wav.h"
#include "playback.h"
/**
* Test the various decoder modules in ctrmus.
*/
int main(int argc, char *argv[])
{
struct decoder_fn decoder;
if(argc != 2)
{
puts("FILE is required.");
printf("%s FILE\n", argv[0]);
return 0;
}
#if 0
switch(getFileType(argv[1]))
{
case FILE_TYPE_WAV:
setWav(&decoder);
break;
case FILE_TYPE_FLAC:
setFlac(&decoder);
break;
case FILE_TYPE_OPUS:
setOpus(&decoder);
break;
case FILE_TYPE_MP3:
setMp3(&decoder);
break;
case FILE_TYPE_VORBIS:
setVorbis(&decoder);
break;
default:
goto err;
}
#endif
return 0;
err:
puts("Error");
return -1;
}
#else
#pragma message ( "Test ignored for 3DS build." )
#endif

View File

@@ -1,4 +1,3 @@
#include <3ds.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>

View File

@@ -1,4 +1,3 @@
#include <3ds.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>

View File

@@ -1,3 +1,4 @@
#include <stdint.h>
#include "playback.h" #include "playback.h"
/** /**