1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <gtest/gtest.h>
17 #include "ffrt_inner.h"
18 #include <cstdlib>
19 #include "../common.h"
20 
21 using namespace testing;
22 #ifdef HWTEST_TESTING_EXT_ENABLE
23 using namespace testing::ext;
24 #endif
25 
26 class InitTest : public testing::Test {
27 protected:
SetUpTestCase()28     static void SetUpTestCase()
29     {
30     }
31 
TearDownTestCase()32     static void TearDownTestCase()
33     {
34     }
35 
SetUp()36     virtual void SetUp()
37     {
38     }
39 
TearDown()40     virtual void TearDown()
41     {
42     }
43 };
44 
45 class Env {
46 public:
Env()47     Env()
48     {
49         putenv("FFRT_PATH_HARDWARE=1");
50     }
~Env()51     ~Env()
52     {
53         putenv("FFRT_PATH_HARDWARE=0");
54     }
55 };
56 
57 Env g_env __attribute__ ((init_priority(102)));
HWTEST_F(InitTest, hardware_test, TestSize.Level1)58 HWTEST_F(InitTest, hardware_test, TestSize.Level1)
59 {
60     int x = 0;
61     auto h = ffrt::submit_h(
62         [&]() {
63             x++;
64         }, {}, {});
65     ffrt::wait({h});
66     EXPECT_EQ(x, 1);
67 }