mirror of
https://github.com/Goldenkrew3000/OSSP_OpenSource.git
synced 2025-12-19 00:04:44 +10:00
Added the ability to build and run tests
This commit is contained in:
20
src/buildTests.sh
Executable file
20
src/buildTests.sh
Executable file
@@ -0,0 +1,20 @@
|
|||||||
|
gcc runTests.c \
|
||||||
|
configHandler.c \
|
||||||
|
libopensubsonic/httpclient.c \
|
||||||
|
external/cJSON.c \
|
||||||
|
external/md5.c \
|
||||||
|
libopensubsonic/utils.c \
|
||||||
|
libopensubsonic/logger.c \
|
||||||
|
libopensubsonic/crypto.c \
|
||||||
|
libopensubsonic/endpoint_ping.c \
|
||||||
|
libopensubsonic/endpoint_getAlbum.c \
|
||||||
|
libopensubsonic/endpoint_getSong.c \
|
||||||
|
libopensubsonic/endpoint_getPlaylists.c \
|
||||||
|
libopensubsonic/endpoint_getPlaylist.c \
|
||||||
|
libopensubsonic/endpoint_getArtists.c \
|
||||||
|
libopensubsonic/endpoint_getArtist.c \
|
||||||
|
libopensubsonic/endpoint_getLyricsBySongId.c \
|
||||||
|
libopensubsonic/endpoint_getAlbumList.c \
|
||||||
|
libopensubsonic/endpoint_getStarred.c \
|
||||||
|
libopensubsonic/endpoint_scrobble.c \
|
||||||
|
-o tests -lcurl
|
||||||
@@ -6,9 +6,9 @@
|
|||||||
#include "external/cJSON.h"
|
#include "external/cJSON.h"
|
||||||
#include "libopensubsonic/logger.h"
|
#include "libopensubsonic/logger.h"
|
||||||
|
|
||||||
#if defined(__APPLE__) && defined(__MACH__)
|
#if defined(__APPLE__) && defined(__MACH__) && defined(XCODE)
|
||||||
#include "OSSP_Bridge.h"
|
#include "OSSP_Bridge.h"
|
||||||
#endif // defined(__APPLE__) && defined(__MACH__)
|
#endif // defined(__APPLE__) && defined(__MACH__) && defined(__XCODE__)
|
||||||
|
|
||||||
static int rc = 0;
|
static int rc = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -20,12 +20,12 @@
|
|||||||
#include "libopensubsonic/endpoint_getAlbum.h"
|
#include "libopensubsonic/endpoint_getAlbum.h"
|
||||||
#include "libopensubsonic/endpoint_getLyricsBySongId.h"
|
#include "libopensubsonic/endpoint_getLyricsBySongId.h"
|
||||||
|
|
||||||
configHandler_config_t* test_configObj = NULL;
|
configHandler_config_t* configObj = NULL;
|
||||||
|
|
||||||
void test_libopensubsonic_endpoint_ping(void) {
|
void test_libopensubsonic_endpoint_ping(void) {
|
||||||
logger_log_general(__func__, "Testing ping endpoint.");
|
logger_log_general(__func__, "Testing ping endpoint.");
|
||||||
|
|
||||||
opensubsonic_httpClient_URL_t* url = (opensubsonic_httpClient_URL_t*)malloc(sizeof(opensubsonic_httpClient_URL_t));
|
opensubsonic_httpClient_URL_t* url = malloc(sizeof(opensubsonic_httpClient_URL_t));
|
||||||
opensubsonic_httpClient_URL_prepare(&url);
|
opensubsonic_httpClient_URL_prepare(&url);
|
||||||
url->endpoint = OPENSUBSONIC_ENDPOINT_PING;
|
url->endpoint = OPENSUBSONIC_ENDPOINT_PING;
|
||||||
opensubsonic_httpClient_formUrl(&url);
|
opensubsonic_httpClient_formUrl(&url);
|
||||||
@@ -40,7 +40,7 @@ void test_libopensubsonic_endpoint_ping(void) {
|
|||||||
void test_libopensubsonic_endpoint_getStarred(void) {
|
void test_libopensubsonic_endpoint_getStarred(void) {
|
||||||
logger_log_general(__func__, "Testing getStarred endpoint.");
|
logger_log_general(__func__, "Testing getStarred endpoint.");
|
||||||
|
|
||||||
opensubsonic_httpClient_URL_t* url = (opensubsonic_httpClient_URL_t*)malloc(sizeof(opensubsonic_httpClient_URL_t));
|
opensubsonic_httpClient_URL_t* url = malloc(sizeof(opensubsonic_httpClient_URL_t));
|
||||||
opensubsonic_httpClient_URL_prepare(&url);
|
opensubsonic_httpClient_URL_prepare(&url);
|
||||||
url->endpoint = OPENSUBSONIC_ENDPOINT_GETSTARRED;
|
url->endpoint = OPENSUBSONIC_ENDPOINT_GETSTARRED;
|
||||||
opensubsonic_httpClient_formUrl(&url);
|
opensubsonic_httpClient_formUrl(&url);
|
||||||
@@ -55,7 +55,7 @@ void test_libopensubsonic_endpoint_getStarred(void) {
|
|||||||
void test_libopensubsonic_endpoint_getPlaylists(void) {
|
void test_libopensubsonic_endpoint_getPlaylists(void) {
|
||||||
logger_log_general(__func__, "Testing getPlaylists endpoint.");
|
logger_log_general(__func__, "Testing getPlaylists endpoint.");
|
||||||
|
|
||||||
opensubsonic_httpClient_URL_t* url = (opensubsonic_httpClient_URL_t*)malloc(sizeof(opensubsonic_httpClient_URL_t));
|
opensubsonic_httpClient_URL_t* url = malloc(sizeof(opensubsonic_httpClient_URL_t));
|
||||||
opensubsonic_httpClient_URL_prepare(&url);
|
opensubsonic_httpClient_URL_prepare(&url);
|
||||||
url->endpoint = OPENSUBSONIC_ENDPOINT_GETPLAYLISTS;
|
url->endpoint = OPENSUBSONIC_ENDPOINT_GETPLAYLISTS;
|
||||||
opensubsonic_httpClient_formUrl(&url);
|
opensubsonic_httpClient_formUrl(&url);
|
||||||
@@ -70,7 +70,7 @@ void test_libopensubsonic_endpoint_getPlaylists(void) {
|
|||||||
void test_libopensubsonic_endpoint_getPlaylist(void) {
|
void test_libopensubsonic_endpoint_getPlaylist(void) {
|
||||||
logger_log_general(__func__, "Testing getPlaylist endpoint.");
|
logger_log_general(__func__, "Testing getPlaylist endpoint.");
|
||||||
|
|
||||||
opensubsonic_httpClient_URL_t* url = (opensubsonic_httpClient_URL_t*)malloc(sizeof(opensubsonic_httpClient_URL_t));
|
opensubsonic_httpClient_URL_t* url = malloc(sizeof(opensubsonic_httpClient_URL_t));
|
||||||
opensubsonic_httpClient_URL_prepare(&url);
|
opensubsonic_httpClient_URL_prepare(&url);
|
||||||
url->endpoint = OPENSUBSONIC_ENDPOINT_GETPLAYLIST;
|
url->endpoint = OPENSUBSONIC_ENDPOINT_GETPLAYLIST;
|
||||||
url->id = strdup("dkBA3oVi5zpChEVIDVJn4i");
|
url->id = strdup("dkBA3oVi5zpChEVIDVJn4i");
|
||||||
@@ -86,7 +86,7 @@ void test_libopensubsonic_endpoint_getPlaylist(void) {
|
|||||||
void test_libopensubsonic_endpoint_getSong(void) {
|
void test_libopensubsonic_endpoint_getSong(void) {
|
||||||
logger_log_general(__func__, "Testing getSong endpoint.");
|
logger_log_general(__func__, "Testing getSong endpoint.");
|
||||||
|
|
||||||
opensubsonic_httpClient_URL_t* url = (opensubsonic_httpClient_URL_t*)malloc(sizeof(opensubsonic_httpClient_URL_t));
|
opensubsonic_httpClient_URL_t* url = malloc(sizeof(opensubsonic_httpClient_URL_t));
|
||||||
opensubsonic_httpClient_URL_prepare(&url);
|
opensubsonic_httpClient_URL_prepare(&url);
|
||||||
url->endpoint = OPENSUBSONIC_ENDPOINT_GETSONG;
|
url->endpoint = OPENSUBSONIC_ENDPOINT_GETSONG;
|
||||||
url->id = strdup("c24SgyyHpe86IsAwSV73rx");
|
url->id = strdup("c24SgyyHpe86IsAwSV73rx");
|
||||||
@@ -102,7 +102,7 @@ void test_libopensubsonic_endpoint_getSong(void) {
|
|||||||
void test_libopensubsonic_endpoint_getArtists(void) {
|
void test_libopensubsonic_endpoint_getArtists(void) {
|
||||||
logger_log_general(__func__, "Testing getArtists endpoint.");
|
logger_log_general(__func__, "Testing getArtists endpoint.");
|
||||||
|
|
||||||
opensubsonic_httpClient_URL_t* url = (opensubsonic_httpClient_URL_t*)malloc(sizeof(opensubsonic_httpClient_URL_t));
|
opensubsonic_httpClient_URL_t* url = malloc(sizeof(opensubsonic_httpClient_URL_t));
|
||||||
opensubsonic_httpClient_URL_prepare(&url);
|
opensubsonic_httpClient_URL_prepare(&url);
|
||||||
url->endpoint = OPENSUBSONIC_ENDPOINT_GETARTISTS;
|
url->endpoint = OPENSUBSONIC_ENDPOINT_GETARTISTS;
|
||||||
opensubsonic_httpClient_formUrl(&url);
|
opensubsonic_httpClient_formUrl(&url);
|
||||||
@@ -117,7 +117,7 @@ void test_libopensubsonic_endpoint_getArtists(void) {
|
|||||||
void test_libopensubsonic_endpoint_getArtist(void) {
|
void test_libopensubsonic_endpoint_getArtist(void) {
|
||||||
logger_log_general(__func__, "Testing getArtist endpoint.");
|
logger_log_general(__func__, "Testing getArtist endpoint.");
|
||||||
|
|
||||||
opensubsonic_httpClient_URL_t* url = (opensubsonic_httpClient_URL_t*)malloc(sizeof(opensubsonic_httpClient_URL_t));
|
opensubsonic_httpClient_URL_t* url = malloc(sizeof(opensubsonic_httpClient_URL_t));
|
||||||
opensubsonic_httpClient_URL_prepare(&url);
|
opensubsonic_httpClient_URL_prepare(&url);
|
||||||
url->endpoint = OPENSUBSONIC_ENDPOINT_GETARTIST;
|
url->endpoint = OPENSUBSONIC_ENDPOINT_GETARTIST;
|
||||||
url->id = strdup("3mZKW6zlodlLW4x4QLDhPr");
|
url->id = strdup("3mZKW6zlodlLW4x4QLDhPr");
|
||||||
@@ -133,7 +133,7 @@ void test_libopensubsonic_endpoint_getArtist(void) {
|
|||||||
void test_libopensubsonic_endpoint_getAlbumList(void) {
|
void test_libopensubsonic_endpoint_getAlbumList(void) {
|
||||||
logger_log_general(__func__, "Testing getAlbumList endpoint.");
|
logger_log_general(__func__, "Testing getAlbumList endpoint.");
|
||||||
|
|
||||||
opensubsonic_httpClient_URL_t* url = (opensubsonic_httpClient_URL_t*)malloc(sizeof(opensubsonic_httpClient_URL_t));
|
opensubsonic_httpClient_URL_t* url = malloc(sizeof(opensubsonic_httpClient_URL_t));
|
||||||
opensubsonic_httpClient_URL_prepare(&url);
|
opensubsonic_httpClient_URL_prepare(&url);
|
||||||
url->endpoint = OPENSUBSONIC_ENDPOINT_GETALBUMLIST;
|
url->endpoint = OPENSUBSONIC_ENDPOINT_GETALBUMLIST;
|
||||||
url->type = OPENSUBSONIC_ENDPOINT_GETALBUMLIST_RECENT;
|
url->type = OPENSUBSONIC_ENDPOINT_GETALBUMLIST_RECENT;
|
||||||
@@ -150,7 +150,7 @@ void test_libopensubsonic_endpoint_getAlbumList(void) {
|
|||||||
void test_libopensubsonic_endpoint_getAlbum(void) {
|
void test_libopensubsonic_endpoint_getAlbum(void) {
|
||||||
logger_log_general(__func__, "Testing getAlbum endpoint.");
|
logger_log_general(__func__, "Testing getAlbum endpoint.");
|
||||||
|
|
||||||
opensubsonic_httpClient_URL_t* url = (opensubsonic_httpClient_URL_t*)malloc(sizeof(opensubsonic_httpClient_URL_t));
|
opensubsonic_httpClient_URL_t* url = malloc(sizeof(opensubsonic_httpClient_URL_t));
|
||||||
opensubsonic_httpClient_URL_prepare(&url);
|
opensubsonic_httpClient_URL_prepare(&url);
|
||||||
url->endpoint = OPENSUBSONIC_ENDPOINT_GETALBUM;
|
url->endpoint = OPENSUBSONIC_ENDPOINT_GETALBUM;
|
||||||
url->id = strdup("5OjqcCVp8LbDfamfubZxFN");
|
url->id = strdup("5OjqcCVp8LbDfamfubZxFN");
|
||||||
@@ -166,7 +166,7 @@ void test_libopensubsonic_endpoint_getAlbum(void) {
|
|||||||
void test_libopensubsonic_endpoint_getLyricsBySongId(void) {
|
void test_libopensubsonic_endpoint_getLyricsBySongId(void) {
|
||||||
logger_log_general(__func__, "Testing getLyricsBySongId endpoint.");
|
logger_log_general(__func__, "Testing getLyricsBySongId endpoint.");
|
||||||
|
|
||||||
opensubsonic_httpClient_URL_t* url = (opensubsonic_httpClient_URL_t*)malloc(sizeof(opensubsonic_httpClient_URL_t));
|
opensubsonic_httpClient_URL_t* url = malloc(sizeof(opensubsonic_httpClient_URL_t));
|
||||||
opensubsonic_httpClient_URL_prepare(&url);
|
opensubsonic_httpClient_URL_prepare(&url);
|
||||||
url->endpoint = OPENSUBSONIC_ENDPOINT_GETLYRICSBYSONGID;
|
url->endpoint = OPENSUBSONIC_ENDPOINT_GETLYRICSBYSONGID;
|
||||||
url->id = strdup("pvu323svJrim683Xf8fBV8");
|
url->id = strdup("pvu323svJrim683Xf8fBV8");
|
||||||
@@ -179,9 +179,16 @@ void test_libopensubsonic_endpoint_getLyricsBySongId(void) {
|
|||||||
opensubsonic_httpClient_URL_cleanup(&url);
|
opensubsonic_httpClient_URL_cleanup(&url);
|
||||||
}
|
}
|
||||||
|
|
||||||
void runTests(void) {
|
int main(void) {
|
||||||
|
int rc = 0;
|
||||||
|
|
||||||
// Read config file
|
// Read config file
|
||||||
configHandler_Read(&test_configObj);
|
rc = configHandler_Read(&configObj);
|
||||||
|
if (rc != 0) {
|
||||||
|
printf("Could not read config file.\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
opensubsonic_crypto_generateLogin();
|
||||||
|
|
||||||
// Run tests
|
// Run tests
|
||||||
test_libopensubsonic_endpoint_ping();
|
test_libopensubsonic_endpoint_ping();
|
||||||
@@ -195,6 +202,6 @@ void runTests(void) {
|
|||||||
test_libopensubsonic_endpoint_getLyricsBySongId();
|
test_libopensubsonic_endpoint_getLyricsBySongId();
|
||||||
|
|
||||||
// Free config file
|
// Free config file
|
||||||
configHandler_Free(&test_configObj);
|
configHandler_Free(&configObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user