4f59f2f2创建于 2025年12月20日历史提交
/**
 * Copyright (c) 2025 Huawei Technologies Co., Ltd.
 * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
 * CANN Open Software License Agreement Version 2.0 (the "License").
 * Please refer to the License for details. You may not use this file except in compliance with the License.
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
 * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
 * See LICENSE in the root of the software repository for the full text of the License.
 */

/*!
 * \file main_aclnn.cpp
 * \brief 本文件作为 GTest 用例 main 桩文件, 一般不需修改任何内容.
 */

#include <gtest/gtest.h>
#include <aclnn/aclnn_base.h>
#include "tests/utils/platform.h"
#include "tests/utils/log.h"

using Platform = ops::adv::tests::utils::Platform;

int main(int argc, char **argv)
{
    /**
     * 加载 OpProto.so, OpTiling.so
     * 注意必须加载 OpProto.so, OpTiling.so, 因为加载时才会触发框架(register) 执行算子处理函数注册.
     */
    Platform platform;
    Platform::SetGlobalPlatform(&platform);
    if (!platform.InitArgsInfo(argc, argv)) {
        return 1;
    }
    if (!platform.LoadOpProtoSo()) {
        return 1;
    }
    if (!platform.LoadOpTilingSo()) {
        return 1;
    }

    testing::InitGoogleTest(&argc, argv);
    int ret = RUN_ALL_TESTS();

    auto aclRet = aclnnFinalize();
    if (aclRet != ACL_SUCCESS) {
        LOG_ERR("aclnnFinalize ERROR: %d", aclRet);
        return aclRet;
    }
    if (!platform.UnLoadOpTilingSo()) {
        return 1;
    }
    if (!platform.UnLoadOpProtoSo()) {
        return 1;
    }

    return ret;
}