• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  *
4  * HDF is dual licensed: you can use it either under the terms of
5  * the GPL, or the BSD license, at your option.
6  * See the LICENSE file in the root of this repository for complete details.
7  */
8 
9 #include "audio_dai_base_test.h"
10 #include "audio_dai_base.h"
11 #include "audio_driver_log.h"
12 
13 #define HDF_LOG_TAG audio_dai_base_test
14 
DaiDataFromCardTest(void)15 int32_t DaiDataFromCardTest(void)
16 {
17     struct AudioCard card;
18     if (DaiDataFromCard(NULL) != NULL) {
19         return HDF_FAILURE;
20     }
21 
22     (void)memset_s(&card, sizeof(struct AudioCard), 0, sizeof(struct AudioCard));
23     if (DaiDataFromCard(&card) != NULL) {
24         return HDF_FAILURE;
25     }
26     return HDF_SUCCESS;
27 }
28 
DaiGetConfigInfoTest(void)29 int32_t DaiGetConfigInfoTest(void)
30 {
31     struct HdfDeviceObject device;
32     struct DaiData data;
33     (void)memset_s(&device, sizeof(struct HdfDeviceObject), 0, sizeof(struct HdfDeviceObject));
34     (void)memset_s(&data, sizeof(struct DaiData), 0, sizeof(struct DaiData));
35 
36     if (DaiGetConfigInfo(NULL, NULL) == HDF_SUCCESS) {
37         return HDF_FAILURE;
38     }
39 
40     if (DaiGetConfigInfo(&device, &data) == HDF_SUCCESS) {
41         return HDF_FAILURE;
42     }
43     return HDF_SUCCESS;
44 }
45 
DaiCheckSampleRateTest(void)46 int32_t DaiCheckSampleRateTest(void)
47 {
48     if (DaiCheckSampleRate(0) == HDF_SUCCESS) {
49         return HDF_FAILURE;
50     }
51 
52     if (DaiCheckSampleRate(AUDIO_SAMPLE_RATE_8000) != HDF_SUCCESS) {
53         return HDF_FAILURE;
54     }
55     return HDF_SUCCESS;
56 }
57 
DaiSetConfigInfoTest(void)58 int32_t DaiSetConfigInfoTest(void)
59 {
60     struct DaiData data;
61     if (DaiSetConfigInfo(NULL) == HDF_SUCCESS) {
62         return HDF_FAILURE;
63     }
64 
65     (void)memset_s(&data, sizeof(struct DaiData), 0, sizeof(struct DaiData));
66     if (DaiSetConfigInfo(&data) == HDF_SUCCESS) {
67         return HDF_FAILURE;
68     }
69     return HDF_SUCCESS;
70 }
71 
72