tests: Remove scons-based testing code
Completes issue #4: Investigate CTest Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
a8abbdfdcc
commit
524d1886f9
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
* Copyright 2016 (c) Anna Schumaker.
|
||||
*/
|
||||
#ifndef TESTS_GUI_H
|
||||
#define TESTS_GUI_H
|
||||
|
||||
#ifdef TEST_NEED_AUDIO
|
||||
void __audio_can_accel() {}
|
||||
void __audio_favorite() {}
|
||||
void __audio_hide() {}
|
||||
void __audio_pause_changed() {}
|
||||
void __audio_seek() {}
|
||||
|
||||
void __artwork_select_cover() {}
|
||||
#endif
|
||||
|
||||
#ifdef TEST_NEED_SIDEBAR
|
||||
void __sidebar_keypress() {}
|
||||
void __sidebar_resize() {}
|
||||
void __sidebar_selection_changed() {}
|
||||
#endif /* TEST_NEED_SIDEBAR */
|
||||
|
||||
#ifdef TEST_NEED_COLLECTION
|
||||
void __collection_add() {}
|
||||
void __collection_choose() {}
|
||||
#endif /* TEST_NEED_COLLECTION */
|
||||
|
||||
#ifdef TEST_NEED_PLAYLIST
|
||||
void __playlist_keypress() {}
|
||||
void __playlist_selection_changed() {}
|
||||
#endif /* TEST_NEED_PLAYLIST */
|
||||
|
||||
#ifdef TEST_NEED_QUEUE
|
||||
void __queue_disabled() {}
|
||||
void __queue_filter() {}
|
||||
void __queue_filter_how_changed() {}
|
||||
void __queue_random() {}
|
||||
void __queue_repeat() {}
|
||||
#endif /* TEST_NEED_QUEUE */
|
||||
|
||||
#ifdef TEST_NEED_WINDOW
|
||||
void __window_configure() {}
|
||||
void __window_state() {}
|
||||
#endif /* TEST_NEED_WINDOW */
|
||||
|
||||
#endif /* TESTS_GUI_H */
|
|
@ -4,12 +4,7 @@
|
|||
#ifndef OCARINA_TESTS_TEST_H
|
||||
#define OCARINA_TESTS_TEST_H
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <glib.h>
|
||||
#include <glib/gstdio.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
#define g_assert_cmpstr_free(lhs, cmp, rhs) \
|
||||
|
@ -18,101 +13,4 @@ do { \
|
|||
g_free(lhs); \
|
||||
} while (0)
|
||||
|
||||
|
||||
#ifndef __cplusplus
|
||||
static inline gchar *lutos(long unsigned int u)
|
||||
{ return g_strdup_printf("%lu", u); }
|
||||
static inline gchar *stos(const char *s) { return g_strdup(s); }
|
||||
static inline gchar *utos(unsigned int u) { return g_strdup_printf("%u", u); }
|
||||
static inline gchar *ltos(long int l) { return g_strdup_printf("%lu", l); }
|
||||
static inline gchar *itos(int i) { return g_strdup_printf("%i", i); }
|
||||
static inline gchar *ftos(float f) { return g_strdup_printf("%f", f); }
|
||||
static inline gchar *btos(bool b) { return g_strdup(b ? "true" : "false"); }
|
||||
static inline gchar *ptos(void *p) { return g_strdup_printf("%p", p); }
|
||||
|
||||
|
||||
#define tostring(x) (_Generic((x), \
|
||||
char *: stos, \
|
||||
const char *: stos, \
|
||||
unsigned char: utos, \
|
||||
bool: btos, \
|
||||
long unsigned int: lutos, \
|
||||
unsigned int: utos, \
|
||||
short unsigned int: utos, \
|
||||
long int: ltos, \
|
||||
int: itos, \
|
||||
float:ftos, \
|
||||
void *:ptos \
|
||||
) (x))
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
struct UnitTest {
|
||||
const char *t_name;
|
||||
void (*t_func)();
|
||||
};
|
||||
|
||||
extern struct UnitTest unit_tests[];
|
||||
extern unsigned int unit_tests_size;;
|
||||
|
||||
|
||||
#define UNIT_TEST(name, func) \
|
||||
[__COUNTER__] = { \
|
||||
.t_name = name, \
|
||||
.t_func = func, \
|
||||
}
|
||||
|
||||
|
||||
#define DECLARE_UNIT_TESTS(...) \
|
||||
struct UnitTest unit_tests[] = {\
|
||||
__VA_ARGS__ \
|
||||
}; \
|
||||
unsigned int unit_tests_size = __COUNTER__
|
||||
|
||||
|
||||
extern unsigned int tests_failed;
|
||||
void test_strings_equal(gchar *, gchar *, unsigned int);
|
||||
void test_strings_not_equal(gchar *, gchar *, unsigned int);
|
||||
void loop_strings_equal(gchar *, gchar *, unsigned int, unsigned int);
|
||||
void loop_strings_not_equal(gchar *, gchar *, unsigned int, unsigned int);
|
||||
|
||||
|
||||
#define test_equal(lhs, rhs) \
|
||||
test_strings_equal(tostring(lhs), tostring(rhs), __LINE__)
|
||||
|
||||
#define test_not_equal(lhs, rhs) \
|
||||
test_strings_not_equal(tostring(lhs), tostring(rhs), __LINE__)
|
||||
|
||||
#define test_str_equal(lhs, rhs) \
|
||||
test_strings_equal(lhs, g_strdup(rhs), __LINE__)
|
||||
|
||||
#define test_loop_equal(lhs, rhs, i) \
|
||||
if (1) { \
|
||||
loop_strings_equal(tostring(lhs), tostring(rhs), i, __LINE__); \
|
||||
if (tests_failed > 0) \
|
||||
break; \
|
||||
}
|
||||
|
||||
#define test_loop_not_equal(lhs, rhs, i) \
|
||||
if (1) { \
|
||||
loop_strings_not_equal(tostring(lhs), tostring(rhs), i, __LINE__); \
|
||||
if (tests_failed > 0) \
|
||||
break; \
|
||||
}
|
||||
|
||||
#define test_loop_str_equal(lhs, rhs, i) \
|
||||
if (1) { \
|
||||
loop_strings_equal(lhs, tostring(rhs), i, __LINE__); \
|
||||
if (tests_failed > 0) \
|
||||
break; \
|
||||
}
|
||||
|
||||
#define test_loop_passed() \
|
||||
if (tests_failed == 0) \
|
||||
test_equal(tests_failed, 0)
|
||||
|
||||
|
||||
gchar *test_data_file(const gchar *);
|
||||
bool test_data_file_exists(const gchar *);
|
||||
|
||||
#endif /* OCARINA_TESTS_TEST_H */
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
invalid_track
|
|
@ -95,3 +95,8 @@ gen_track(32 24 "Serenade of Water")
|
|||
gen_track(33 25 "Nocturne of Shadow")
|
||||
gen_track(34 23 "Prelude of Light")
|
||||
gen_track(35 27 "Requiem of Spirit")
|
||||
|
||||
#
|
||||
# Generate an invalid track
|
||||
#
|
||||
file(WRITE invalid_track "abcdefghijklmnopqrstuvwxyz")
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
Koji Kondo
|
||||
1998 Hyrule Symphony
|
||||
Game
|
||||
243 Title Theme
|
||||
130 Kokiri Forest
|
||||
227 Hyrule Field
|
||||
130 Hyrule Castle
|
||||
206 Lon Lon Ranch
|
||||
186 Kakariko Village
|
||||
178 Death Mountain
|
||||
221 Zora's Domain
|
||||
273 Gerudo Valley
|
||||
66 Ganondorf
|
||||
185 Princess Zelda
|
||||
232 Ocarina Medley
|
||||
288 The Legend of Zelda Medley
|
|
@ -1,38 +0,0 @@
|
|||
Koji Kondo
|
||||
1998 Ocarina of Time
|
||||
Video Game
|
||||
170 Title Theme
|
||||
80 Deku Tree
|
||||
46 Fairy Flying
|
||||
71 House
|
||||
112 Kokiri Forest
|
||||
133 Shop
|
||||
134 Battle
|
||||
164 Inside the Deku Tree
|
||||
153 Boss Battle
|
||||
327 Hyrule Field Main Theme
|
||||
103 Market
|
||||
90 Hyrule Castle Courtyard
|
||||
62 Ocarina Songs
|
||||
101 Ocarina of Time
|
||||
271 LonLon Ranch
|
||||
204 Kakariko Village
|
||||
75 Lost Woods
|
||||
171 Zora's Domain
|
||||
72 Great Fairy's Fountain
|
||||
159 Temple of Time
|
||||
124 Chamber of the Sages
|
||||
98 Horse Race
|
||||
193 Kakariko Village Orchestra
|
||||
99 Windmill Hut
|
||||
172 Gerudo Valley
|
||||
147 Ganondorf Battle
|
||||
191 Last Battle
|
||||
34 Zelda's Ocarina
|
||||
433 Staff Credits Theme
|
||||
18 Minuet of Forest
|
||||
24 Bolero of Fire
|
||||
24 Serenade of Water
|
||||
25 Nocturne of Shadow
|
||||
23 Prelude of Light
|
||||
27 Requiem of Spirit
|
|
@ -1,47 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
function check_cmd()
|
||||
{
|
||||
echo -n "Checking for $1 ... "
|
||||
CMD=$(which $1 2>/dev/null)
|
||||
if [ $? != 0 ]; then
|
||||
echo "$1 not found"
|
||||
exit 1
|
||||
fi
|
||||
echo $CMD
|
||||
}
|
||||
check_cmd ffmpeg
|
||||
check_cmd vorbiscomment
|
||||
|
||||
TRACK=1
|
||||
FFMPEG="ffmpeg -hide_banner -nostdin -f s16le -i /dev/zero -codec libvorbis -loglevel warning"
|
||||
|
||||
while read -r line; do
|
||||
if [ -z "$ARTIST" ]; then
|
||||
ARTIST="$line"
|
||||
elif [ -z "$ALBUM" ]; then
|
||||
YEAR=$(echo "$line" | cut -f 1 -d ' ')
|
||||
ALBUM=$(echo "$line" | cut -f 1 -d ' ' --complement)
|
||||
mkdir -p "$ALBUM"
|
||||
elif [ -z "$GENRE" ]; then
|
||||
GENRE="$line"
|
||||
else
|
||||
LENGTH=$(echo "$line" | cut -f 1 -d ' ')
|
||||
TITLE=$(echo "$line" | cut -f -1 -d ' ' --complement)
|
||||
NUMBER=$(printf "%02d" $TRACK)
|
||||
FILE="$ALBUM/$NUMBER - $TITLE.ogg"
|
||||
|
||||
if [ ! -f "$FILE" ]; then
|
||||
echo "$FILE"
|
||||
$FFMPEG -t "$LENGTH" "$FILE"
|
||||
vorbiscomment -w "$FILE" -t "TITLE=$TITLE" \
|
||||
-t "ARTIST=$ARTIST" \
|
||||
-t "ALBUM=$ALBUM" \
|
||||
-t "GENRE=$GENRE" \
|
||||
-t "DATE=$YEAR" \
|
||||
-t "TRACKNUMBER=$NUMBER"
|
||||
fi
|
||||
|
||||
let TRACK=$TRACK+1
|
||||
fi
|
||||
done < $1
|
|
@ -1 +0,0 @@
|
|||
abcdefghijklmnopqrstuvwxyz
|
|
@ -4,15 +4,6 @@ file
|
|||
date
|
||||
idle
|
||||
database
|
||||
tags/artist
|
||||
tags/album
|
||||
tags/genre
|
||||
tags/library
|
||||
tags/track
|
||||
queue
|
||||
playlists/system
|
||||
playlists/artist
|
||||
playlists/library
|
||||
playlist
|
||||
tempq
|
||||
audio
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
system
|
||||
artist
|
||||
library
|
|
@ -1,6 +1,5 @@
|
|||
album
|
||||
artist
|
||||
generic
|
||||
album
|
||||
genre
|
||||
library
|
||||
track
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright 2013 (c) Anna Schumaker.
|
||||
#
|
||||
# Generate a test library in /tmp
|
||||
#
|
||||
|
||||
# $1 - File, $2 - Directory number
|
||||
function tag_file()
|
||||
{
|
||||
artist="Artist $2"
|
||||
album="Album $2"
|
||||
let date=2008+$2
|
||||
vorbiscomment -w $1 -t "ARTIST=$artist" -t "ALBUM=$album" -t "DATE=$date"
|
||||
}
|
||||
|
||||
|
||||
mkdir -p /tmp/ocarina/dir{1..5}
|
||||
|
||||
for i in $(seq 5); do
|
||||
cp tests/Music/*.ogg /tmp/ocarina/dir$i/
|
||||
|
||||
for f in /tmp/ocarina/dir$i/*; do
|
||||
tag_file $f $i
|
||||
done
|
||||
done
|
|
@ -7,7 +7,6 @@
|
|||
#include <gui/idle.h>
|
||||
#include <gui/settings.h>
|
||||
#include <gui/view.h>
|
||||
#include <tests/gui.h>
|
||||
#include <tests/test.h>
|
||||
|
||||
static const unsigned int N = 100;
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <gui/builder.h>
|
||||
#include <gui/model.h>
|
||||
#include <tests/test.h>
|
||||
#include <string.h>
|
||||
|
||||
unsigned int count_insert = 0;
|
||||
unsigned int count_delete = 0;
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#include <gui/model.h>
|
||||
#include <gui/playlist.h>
|
||||
#include <gui/view.h>
|
||||
#include <tests/gui.h>
|
||||
#include <tests/test.h>
|
||||
|
||||
struct core_init_data init_data;
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#include <gui/builder.h>
|
||||
#include <gui/queue.h>
|
||||
#include <gui/view.h>
|
||||
#include <tests/gui.h>
|
||||
#include <tests/test.h>
|
||||
|
||||
static void *test_queue_init(struct queue *queue, void *data)
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
#include <gui/builder.h>
|
||||
#include <gui/settings.h>
|
||||
#include <gui/sidebar.h>
|
||||
#include <tests/gui.h>
|
||||
#include <tests/test.h>
|
||||
|
||||
static void test_sidebar()
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
#include <gui/model.h>
|
||||
#include <gui/settings.h>
|
||||
#include <gui/view.h>
|
||||
#include <tests/gui.h>
|
||||
#include <tests/test.h>
|
||||
|
||||
const gchar *QUEUE_SETTINGS[Q_MODEL_N_COLUMNS] = {
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
#include <gui/settings.h>
|
||||
#include <gui/view.h>
|
||||
#include <gui/window.h>
|
||||
#include <tests/gui.h>
|
||||
#include <tests/test.h>
|
||||
|
||||
GMainLoop *main_loop;
|
||||
|
|
|
@ -1,94 +0,0 @@
|
|||
/*
|
||||
* Copyright 2015 (c) Anna Schumaker.
|
||||
*/
|
||||
#include <tests/test.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef CONFIG_TESTING
|
||||
static const char *str = "Enabled";
|
||||
#else /* CONFIG_TESTING */
|
||||
static const char *str = "Disabled";
|
||||
#endif /* CONFIG_TESTING */
|
||||
|
||||
static unsigned int counter = 0;
|
||||
static unsigned int inc_counter() { return counter++; }
|
||||
|
||||
static void test_passing_tests()
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
test_equal(0, 0);
|
||||
test_equal("2", "2");
|
||||
test_equal((void *)4, (void *)4);
|
||||
test_equal(str, "Enabled");
|
||||
test_equal(inc_counter(), 0);
|
||||
test_equal((bool)true, (bool)true);
|
||||
|
||||
for (i = 0; i < 10; i++)
|
||||
test_loop_equal(i, i, i);
|
||||
test_loop_passed();
|
||||
|
||||
test_not_equal(0, 1);
|
||||
test_not_equal("2", "3");
|
||||
test_not_equal((void *)4, (void *)5);
|
||||
test_not_equal(str, "Disabled");
|
||||
test_not_equal(inc_counter(), 2);
|
||||
test_not_equal((bool)true, (bool)false);
|
||||
|
||||
for (i = 0; i < 10; i++)
|
||||
test_loop_not_equal(i, i + 1, i);
|
||||
test_loop_passed();
|
||||
}
|
||||
|
||||
static void test_failing_tests()
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
test_equal(0, 1);
|
||||
test_equal("2", "3");
|
||||
test_equal((void *)4, (void *)5);
|
||||
test_equal(str, "Disabled");
|
||||
test_equal(inc_counter(), 3);
|
||||
test_equal((bool)true, (bool)false);
|
||||
|
||||
for (i = 0; i < 10; i++)
|
||||
test_loop_equal(i, i + 1, i);
|
||||
test_loop_passed();
|
||||
|
||||
test_not_equal(0, 0);
|
||||
test_not_equal("2", "2");
|
||||
test_not_equal((void *)4, (void *)4);
|
||||
test_not_equal(str, "Enabled");
|
||||
test_not_equal(inc_counter(), 3);
|
||||
test_not_equal((bool)true, (bool)true);
|
||||
|
||||
for (i = 0; i < 10; i++)
|
||||
test_loop_not_equal(i, i, i);
|
||||
test_loop_passed();
|
||||
tests_failed = 0;
|
||||
}
|
||||
|
||||
static void test_utilities()
|
||||
{
|
||||
gchar *dir = test_data_file(NULL);
|
||||
gchar *file = test_data_file("sanity");
|
||||
const gchar *data = g_get_user_data_dir();
|
||||
gchar *ddata = g_strjoin("/", data, "ocarina-test", NULL);
|
||||
gchar *fdata = g_strjoin("/", data, "ocarina-test", "sanity", NULL);
|
||||
|
||||
test_equal(dir, ddata);
|
||||
test_equal(file, fdata);
|
||||
test_equal(test_data_file_exists(NULL), (bool)false);
|
||||
test_equal(test_data_file_exists("sanity"), (bool)false);
|
||||
|
||||
g_free(dir);
|
||||
g_free(file);
|
||||
g_free(ddata);
|
||||
g_free(fdata);
|
||||
}
|
||||
|
||||
DECLARE_UNIT_TESTS(
|
||||
UNIT_TEST("Sanity Check", test_passing_tests),
|
||||
UNIT_TEST("Sanity Check (All should fail)", test_failing_tests),
|
||||
UNIT_TEST("Sanity Check Utility Functions", test_utilities),
|
||||
);
|
177
tests/test.c
177
tests/test.c
|
@ -1,177 +0,0 @@
|
|||
/*
|
||||
* Copyright 2015 (c) Anna Schumaker.
|
||||
*/
|
||||
#include <tests/test.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
static unsigned int test_num;
|
||||
unsigned int tests_failed = 0;
|
||||
|
||||
|
||||
static void test_print_result(bool passed, unsigned int line)
|
||||
{
|
||||
printf("\t%u: ", test_num++);
|
||||
if (passed)
|
||||
printf("Success!\n");
|
||||
else {
|
||||
printf("Failed at line %u.\n", line);
|
||||
tests_failed++;
|
||||
}
|
||||
}
|
||||
|
||||
static void test_loop_print_result(bool passed, unsigned int i,
|
||||
unsigned int line)
|
||||
{
|
||||
if (!passed) {
|
||||
printf("\t%u: ", test_num++);
|
||||
printf("Failed loop at line: %u (i = %u)\n", line, i);
|
||||
tests_failed++;
|
||||
}
|
||||
}
|
||||
|
||||
static void test_equal_common(gchar *lhs, gchar *rhs, bool passed)
|
||||
{
|
||||
if (!passed) {
|
||||
printf("\t\t Actual: %s\n", lhs);
|
||||
printf("\t\tExpected: %s\n", rhs);
|
||||
}
|
||||
g_free(lhs);
|
||||
g_free(rhs);
|
||||
}
|
||||
|
||||
static void test_not_equal_common(gchar *lhs, gchar *rhs, bool passed)
|
||||
{
|
||||
if (!passed)
|
||||
printf("\t\tUnexpected: %s\n", lhs);
|
||||
g_free(lhs);
|
||||
g_free(rhs);
|
||||
}
|
||||
|
||||
/*
|
||||
* lhs and rhs should be newly allocated strings so we can
|
||||
* free them in test{_not}_equal_common().
|
||||
*/
|
||||
void test_strings_equal(gchar *lhs, gchar *rhs, unsigned int line)
|
||||
{
|
||||
bool passed = strcmp(lhs, rhs) == 0;
|
||||
|
||||
test_print_result(passed, line);
|
||||
test_equal_common(lhs, rhs, passed);
|
||||
}
|
||||
|
||||
void test_strings_not_equal(gchar *lhs, gchar *rhs, unsigned int line)
|
||||
{
|
||||
bool passed = strcmp(lhs, rhs) != 0;
|
||||
|
||||
test_print_result(passed, line);
|
||||
test_not_equal_common(lhs, rhs, passed);
|
||||
}
|
||||
|
||||
void loop_strings_equal(gchar *lhs, gchar *rhs, unsigned int i,
|
||||
unsigned int line)
|
||||
{
|
||||
bool passed = strcmp(lhs, rhs) == 0;
|
||||
|
||||
test_loop_print_result(passed, i, line);
|
||||
test_equal_common(lhs, rhs, passed);
|
||||
}
|
||||
|
||||
void loop_strings_not_equal(gchar *lhs, gchar *rhs, unsigned int i,
|
||||
unsigned int line)
|
||||
{
|
||||
bool passed = strcmp(lhs, rhs) != 0;
|
||||
|
||||
test_loop_print_result(passed, i, line);
|
||||
test_not_equal_common(lhs, rhs, passed);
|
||||
}
|
||||
|
||||
static void run_test(struct UnitTest *test)
|
||||
{
|
||||
test_num = 0;
|
||||
|
||||
if (!test->t_name || !test->t_func)
|
||||
return;
|
||||
|
||||
printf("Testing %s\n", test->t_name);
|
||||
test->t_func();
|
||||
printf("\n");
|
||||
|
||||
if (tests_failed > 0)
|
||||
printf("\n%u tests failed =(\n\n", tests_failed);
|
||||
}
|
||||
|
||||
gchar *test_data_file(const gchar *name)
|
||||
{
|
||||
return g_strjoin("/", g_get_user_data_dir(), "ocarina-test", name, NULL);
|
||||
}
|
||||
|
||||
gchar *test_cache_file(const gchar *name)
|
||||
{
|
||||
return g_strjoin("/", g_get_user_cache_dir(), "ocarina-test", name, NULL);
|
||||
}
|
||||
|
||||
bool test_data_file_exists(const gchar *name)
|
||||
{
|
||||
GFileTest test = G_FILE_TEST_EXISTS;
|
||||
gchar *dir;
|
||||
bool ret;
|
||||
|
||||
if (!name)
|
||||
test = G_FILE_TEST_IS_DIR;
|
||||
|
||||
dir = g_strjoin("/", g_get_user_data_dir(), "ocarina-test", name, NULL);
|
||||
ret = g_file_test(dir, test);
|
||||
g_free(dir);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void test_rm_dir(const gchar *path)
|
||||
{
|
||||
const gchar *file = NULL;
|
||||
GDir *dir = g_dir_open(path, 0, NULL);
|
||||
|
||||
if (!dir)
|
||||
return;
|
||||
|
||||
while ((file = g_dir_read_name(dir)) != NULL) {
|
||||
gchar *fullpath = g_strjoin("/", path, file, NULL);
|
||||
if (g_file_test(fullpath, G_FILE_TEST_IS_DIR))
|
||||
test_rm_dir(fullpath);
|
||||
g_remove(fullpath);
|
||||
g_free(fullpath);
|
||||
}
|
||||
|
||||
g_dir_close(dir);
|
||||
g_rmdir(path);
|
||||
}
|
||||
|
||||
static void test_rm_dirs()
|
||||
{
|
||||
gchar *data = test_data_file(NULL);
|
||||
gchar *cache = test_cache_file(NULL);
|
||||
|
||||
test_rm_dir(data);
|
||||
test_rm_dir(cache);
|
||||
|
||||
g_free(data);
|
||||
g_free(cache);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
if (test_data_file_exists(NULL))
|
||||
test_rm_dirs();
|
||||
|
||||
for (i = 0; i < unit_tests_size; i++) {
|
||||
run_test(&unit_tests[i]);
|
||||
if (tests_failed != 0)
|
||||
break;
|
||||
}
|
||||
printf("\n");
|
||||
return tests_failed;
|
||||
}
|
Loading…
Reference in New Issue