From 3fd8a9b3b8d634e57c5cef227983c81dcf8e6c91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20L=C3=B3pez-Cabanillas?= Date: Sun, 17 Nov 2024 20:48:34 +0100 Subject: [PATCH] fixed unit tests --- test/SonivoxTest.cpp | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/test/SonivoxTest.cpp b/test/SonivoxTest.cpp index a201afe8..f8424a8c 100644 --- a/test/SonivoxTest.cpp +++ b/test/SonivoxTest.cpp @@ -14,7 +14,6 @@ * limitations under the License. */ -//#define LOG_NDEBUG 0 #define LOG_TAG "SonivoxTest" #include @@ -52,7 +51,6 @@ class SonivoxTest : public ::testing::TestWithParam= 0) close(mFd); if (mPCMBuffer) { @@ -81,6 +77,7 @@ class SonivoxTest : public ::testing::TestWithParam params = GetParam(); mInputMediaFile = gEnv->getRes() + get<0>(params); mAudioplayTimeMs = get<1>(params); @@ -95,24 +92,35 @@ class SonivoxTest : public ::testing::TestWithParam 0) { string soundfontpath = gEnv->getTmp() + mSoundFont; - memset(&mDLSFile, 0, sizeof(EAS_FILE)); + mFd = open(soundfontpath.c_str(), O_RDONLY | OPEN_FLAG); + ASSERT_GE(mFd, 0) << "Failed to get the file descriptor for file: " << soundfontpath; + + int8_t err = stat(soundfontpath.c_str(), &buf); + ASSERT_EQ(err, 0) << "Failed to get information for file: " << soundfontpath; + + mBase = 0; + mLength = buf.st_size; + memset(&mDLSFile, 0, sizeof(mDLSFile)); - mDLSFile.handle = fopen(soundfontpath.c_str(), "rb"); +#ifdef NEW_HOST_WRAPPER + mDLSFile.handle = fdopen(mFd, "rb"); ASSERT_NE(mDLSFile.handle, nullptr) << "Failed to open " << soundfontpath << " error: " << strerror(errno); -#ifndef NEW_HOST_WRAPPER - mDLSFile.readAt = Read; - mDLSFile.size = Size; +#else + mDLSFile.handle = this; + mDLSFile.readAt = ::readAt; + mDLSFile.size = ::getSize; #endif result = EAS_LoadDLSCollection(mEASDataHandle, nullptr, &mDLSFile); ASSERT_EQ(result, EAS_SUCCESS) << "Failed to load DLS file: " << soundfontpath; - fclose((FILE *) mDLSFile.handle); +#ifdef NEW_HOST_WRAPPER + close(mFd); +#endif } mFd = open(mInputMediaFile.c_str(), O_RDONLY | OPEN_FLAG); ASSERT_GE(mFd, 0) << "Failed to get the file descriptor for file: " << mInputMediaFile; - struct stat buf; int8_t err = stat(mInputMediaFile.c_str(), &buf); ASSERT_EQ(err, 0) << "Failed to get information for file: " << mInputMediaFile; @@ -199,7 +207,6 @@ class SonivoxTest : public ::testing::TestWithParam