Skip to content

Commit 97e50ea

Browse files
nilfm99kylophone
authored andcommitted
add test_cli_parse.c
1 parent 9ae6f90 commit 97e50ea

File tree

2 files changed

+148
-0
lines changed

2 files changed

+148
-0
lines changed

libvmaf/test/meson.build

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,13 @@ test_luminance_tools = executable('test_luminance_tools',
109109
link_with : get_option('default_library') == 'both' ? libvmaf.get_static_lib() : libvmaf,
110110
)
111111

112+
test_cli_parse = executable('test_cli_parse',
113+
['test.c', 'test_cli_parse.c', '../tools/cli_parse.c'],
114+
include_directories : [libvmaf_inc, test_inc, include_directories('../src/'), include_directories('../tools/')],
115+
link_with : get_option('default_library') == 'both' ? libvmaf.get_static_lib() : libvmaf,
116+
c_args : [compat_cflags],
117+
)
118+
112119
if get_option('enable_cuda')
113120
test_ring_buffer = executable('test_ring_buffer',
114121
['test.c', 'test_ring_buffer.c', '../src/cuda/ring_buffer.c', '../src/cuda/picture_cuda.c'],
@@ -143,3 +150,4 @@ test('test_feature', test_feature)
143150
test('test_ciede', test_ciede)
144151
test('test_cambi', test_cambi)
145152
test('test_luminance_tools', test_luminance_tools)
153+
test('test_cli_parse', test_cli_parse)

libvmaf/test/test_cli_parse.c

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
/**
2+
*
3+
* Copyright 2016-2020 Netflix, Inc.
4+
*
5+
* Licensed under the BSD+Patent License (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* https://opensource.org/licenses/BSDplusPatent
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
19+
#include <getopt.h>
20+
21+
#include "test.h"
22+
23+
#include "cli_parse.h"
24+
25+
static char *test_aom_ctc_v1_0()
26+
{
27+
char *argv[7] = {"vmaf", "-r", "ref.y4m", "-d", "dis.y4m", "--aom_ctc", "v1.0"};
28+
int argc = 7;
29+
CLISettings settings;
30+
optind = 1;
31+
cli_parse(argc, argv, &settings);
32+
mu_assert("cli_parse: --aom_ctc v1.0 provided but common_bitdepth enabled", !settings.common_bitdepth);
33+
mu_assert("cli_parse: --aom_ctc v1.0 provided but number of features is not 5", settings.feature_cnt == 5);
34+
mu_assert("cli_parse: --aom_ctc v1.0 provided but number of models is not 2", settings.model_cnt == 2);
35+
cli_free(&settings);
36+
37+
return NULL;
38+
}
39+
40+
static char *test_aom_ctc_v2_0()
41+
{
42+
char *argv[7] = {"vmaf", "-r", "ref.y4m", "-d", "dis.y4m", "--aom_ctc", "v2.0"};
43+
int argc = 7;
44+
CLISettings settings;
45+
optind = 1;
46+
cli_parse(argc, argv, &settings);
47+
mu_assert("cli_parse: --aom_ctc v2.0 provided but common_bitdepth enabled", !settings.common_bitdepth);
48+
mu_assert("cli_parse: --aom_ctc v2.0 provided but number of features is not 5", settings.feature_cnt == 5);
49+
mu_assert("cli_parse: --aom_ctc v2.0 provided but number of models is not 2", settings.model_cnt == 2);
50+
cli_free(&settings);
51+
52+
return NULL;
53+
}
54+
55+
static char *test_aom_ctc_v3_0()
56+
{
57+
char *argv[7] = {"vmaf", "-r", "ref.y4m", "-d", "dis.y4m", "--aom_ctc", "v3.0"};
58+
int argc = 7;
59+
CLISettings settings;
60+
optind = 1;
61+
cli_parse(argc, argv, &settings);
62+
mu_assert("cli_parse: --aom_ctc v3.0 provided but common_bitdepth enabled", !settings.common_bitdepth);
63+
mu_assert("cli_parse: --aom_ctc v3.0 provided but number of features is not 6", settings.feature_cnt == 6);
64+
mu_assert("cli_parse: --aom_ctc v3.0 provided but number of models is not 2", settings.model_cnt == 2);
65+
cli_free(&settings);
66+
67+
return NULL;
68+
}
69+
70+
static char *test_aom_ctc_v4_0()
71+
{
72+
char *argv[7] = {"vmaf", "-r", "ref.y4m", "-d", "dis.y4m", "--aom_ctc", "v4.0"};
73+
int argc = 7;
74+
CLISettings settings;
75+
optind = 1;
76+
cli_parse(argc, argv, &settings);
77+
mu_assert("cli_parse: --aom_ctc v4.0 provided but common_bitdepth enabled", !settings.common_bitdepth);
78+
mu_assert("cli_parse: --aom_ctc v4.0 provided but number of features is not 6", settings.feature_cnt == 6);
79+
mu_assert("cli_parse: --aom_ctc v4.0 provided but number of models is not 2", settings.model_cnt == 2);
80+
cli_free(&settings);
81+
82+
return NULL;
83+
}
84+
85+
static char *test_aom_ctc_v5_0()
86+
{
87+
char *argv[7] = {"vmaf", "-r", "ref.y4m", "-d", "dis.y4m", "--aom_ctc", "v5.0"};
88+
int argc = 7;
89+
CLISettings settings;
90+
optind = 1;
91+
cli_parse(argc, argv, &settings);
92+
mu_assert("cli_parse: --aom_ctc v5.0 provided but common_bitdepth enabled", !settings.common_bitdepth);
93+
mu_assert("cli_parse: --aom_ctc v5.0 provided but number of features is not 6", settings.feature_cnt == 6);
94+
mu_assert("cli_parse: --aom_ctc v5.0 provided but number of models is not 2", settings.model_cnt == 2);
95+
cli_free(&settings);
96+
97+
return NULL;
98+
}
99+
100+
static char *test_aom_ctc_v6_0()
101+
{
102+
char *argv[7] = {"vmaf", "-r", "ref.y4m", "-d", "dis.y4m", "--aom_ctc", "v6.0"};
103+
int argc = 7;
104+
CLISettings settings;
105+
optind = 1;
106+
cli_parse(argc, argv, &settings);
107+
mu_assert("cli_parse: --aom_ctc v6.0 provided but common_bitdepth not enabled", settings.common_bitdepth);
108+
mu_assert("cli_parse: --aom_ctc v6.0 provided but number of features is not 6", settings.feature_cnt == 6);
109+
mu_assert("cli_parse: --aom_ctc v6.0 provided but number of models is not 2", settings.model_cnt == 2);
110+
cli_free(&settings);
111+
112+
return NULL;
113+
}
114+
115+
static char *test_nflx_ctc_v1_0()
116+
{
117+
char *argv[7] = {"vmaf", "-r", "ref.y4m", "-d", "dis.y4m", "--nflx_ctc", "v1.0"};
118+
int argc = 7;
119+
CLISettings settings;
120+
optind = 1;
121+
cli_parse(argc, argv, &settings);
122+
mu_assert("cli_parse: --nflx_ctc v1.0 provided but common_bitdepth enabled", !settings.common_bitdepth);
123+
mu_assert("cli_parse: --nflx_ctc v1.0 provided but number of features is not 3", settings.feature_cnt == 3);
124+
mu_assert("cli_parse: --nflx_ctc v1.0 provided but number of models is not 2", settings.model_cnt == 2);
125+
cli_free(&settings);
126+
127+
return NULL;
128+
}
129+
130+
char *run_tests()
131+
{
132+
mu_run_test(test_aom_ctc_v1_0);
133+
mu_run_test(test_aom_ctc_v2_0);
134+
mu_run_test(test_aom_ctc_v3_0);
135+
mu_run_test(test_aom_ctc_v4_0);
136+
mu_run_test(test_aom_ctc_v5_0);
137+
mu_run_test(test_aom_ctc_v6_0);
138+
mu_run_test(test_nflx_ctc_v1_0);
139+
return NULL;
140+
}

0 commit comments

Comments
 (0)