Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 875bbc8f authored by Lajos Molnar's avatar Lajos Molnar
Browse files

stagefright: Codec2 unit tests for C2Param

Unit tests for C2Params, and param utils

Bug: 30262321
Change-Id: I589f639eae8904a2d17a0f63d07f5479aa14772f
parent 11ca9ffc
Loading
Loading
Loading
Loading
+37 −0
Original line number Diff line number Diff line
# Build the unit tests.
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk

LOCAL_MODULE := codec2_test

LOCAL_MODULE_TAGS := tests

LOCAL_SRC_FILES := \
	vndk/C2UtilTest.cpp \
	C2_test.cpp \
	C2Param_test.cpp \

LOCAL_SHARED_LIBRARIES := \
	libcutils \
	libstagefright_codec2 \
	liblog

LOCAL_C_INCLUDES := \
	frameworks/av/media/libstagefright/codec2/include \
	frameworks/av/media/libstagefright/codec2/vndk/include \
	$(TOP)/frameworks/native/include/media/openmax \

LOCAL_CFLAGS += -Werror -Wall -std=c++14
LOCAL_CLANG := true

include $(BUILD_NATIVE_TEST)

# Include subdirectory makefiles
# ============================================================

# If we're building with ONE_SHOT_MAKEFILE (mm, mmm), then what the framework
# team really wants is to build the stuff defined by this makefile.
ifeq (,$(ONE_SHOT_MAKEFILE))
include $(call first-makefiles-under,$(LOCAL_PATH))
endif
+2687 −0

File added.

Preview size limit exceeded, changes collapsed.

+78 −0
Original line number Diff line number Diff line
/*
 * Copyright 2014 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

//#define LOG_NDEBUG 0
#define LOG_TAG "C2_test"

#include <gtest/gtest.h>

#include <C2.h>

namespace android {

/* ======================================= STATIC TESTS ======================================= */

template<int N>
struct c2_const_checker
{
    inline constexpr static int num() { return N; }
};

constexpr auto min_i32_i32 = c2_min(int32_t(1), int32_t(2));
static_assert(std::is_same<decltype(min_i32_i32), const int32_t>::value, "should be int32_t");
constexpr auto min_i32_i64 = c2_min(int32_t(3), int64_t(2));
static_assert(std::is_same<decltype(min_i32_i64), const int64_t>::value, "should be int64_t");
constexpr auto min_i8_i32 = c2_min(int8_t(0xff), int32_t(0xffffffff));
static_assert(std::is_same<decltype(min_i8_i32), const int32_t>::value, "should be int32_t");

static_assert(c2_const_checker<min_i32_i32>::num() == 1, "should be 1");
static_assert(c2_const_checker<min_i32_i64>::num() == 2, "should be 2");
static_assert(c2_const_checker<min_i8_i32>::num() == 0xffffffff, "should be 0xffffffff");

constexpr auto min_u32_u32 = c2_min(uint32_t(1), uint32_t(2));
static_assert(std::is_same<decltype(min_u32_u32), const uint32_t>::value, "should be uint32_t");
constexpr auto min_u32_u64 = c2_min(uint32_t(3), uint64_t(2));
static_assert(std::is_same<decltype(min_u32_u64), const uint32_t>::value, "should be uint32_t");
constexpr auto min_u32_u8 = c2_min(uint32_t(0xffffffff), uint8_t(0xff));
static_assert(std::is_same<decltype(min_u32_u8), const uint8_t>::value, "should be uint8_t");

static_assert(c2_const_checker<min_u32_u32>::num() == 1, "should be 1");
static_assert(c2_const_checker<min_u32_u64>::num() == 2, "should be 2");
static_assert(c2_const_checker<min_u32_u8>::num() == 0xff, "should be 0xff");

constexpr auto max_i32_i32 = c2_max(int32_t(1), int32_t(2));
static_assert(std::is_same<decltype(max_i32_i32), const int32_t>::value, "should be int32_t");
constexpr auto max_i32_i64 = c2_max(int32_t(3), int64_t(2));
static_assert(std::is_same<decltype(max_i32_i64), const int64_t>::value, "should be int64_t");
constexpr auto max_i8_i32 = c2_max(int8_t(0xff), int32_t(0xffffffff));
static_assert(std::is_same<decltype(max_i8_i32), const int32_t>::value, "should be int32_t");

static_assert(c2_const_checker<max_i32_i32>::num() == 2, "should be 2");
static_assert(c2_const_checker<max_i32_i64>::num() == 3, "should be 3");
static_assert(c2_const_checker<max_i8_i32>::num() == 0xffffffff, "should be 0xffffffff");

constexpr auto max_u32_u32 = c2_max(uint32_t(1), uint32_t(2));
static_assert(std::is_same<decltype(max_u32_u32), const uint32_t>::value, "should be uint32_t");
constexpr auto max_u32_u64 = c2_max(uint32_t(3), uint64_t(2));
static_assert(std::is_same<decltype(max_u32_u64), const uint64_t>::value, "should be uint64_t");
constexpr auto max_u32_u8 = c2_max(uint32_t(0x7fffffff), uint8_t(0xff));
static_assert(std::is_same<decltype(max_u32_u8), const uint32_t>::value, "should be uint32_t");

static_assert(c2_const_checker<max_u32_u32>::num() == 2, "should be 2");
static_assert(c2_const_checker<max_u32_u64>::num() == 3, "should be 3");
static_assert(c2_const_checker<max_u32_u8>::num() == 0x7fffffff, "should be 0x7fffffff");

} // namespace android
+40 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <util/_C2MacroUtils.h>

/** \file
 * Tests for vndk/util.
 */

/* --------------------------------------- _C2MacroUtils --------------------------------------- */

static_assert(0 == _C2_ARGC(), "should be 0");
static_assert(1 == _C2_ARGC(1), "should be 1");
static_assert(2 == _C2_ARGC(1, 2), "should be 2");
static_assert(64 == _C2_ARGC(
        1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
        26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
        49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64), "should be 64");

static_assert(0 == _C2_ARGC(,), "should be 0");
static_assert(1 == _C2_ARGC(1,), "should be 1");
static_assert(2 == _C2_ARGC(1, 2,), "should be 2");
static_assert(64 == _C2_ARGC(
        1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
        26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
        49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,), "should be 64");