1#! /usr/bin/env perl
2# Copyright 2020 The OpenSSL Project Authors. All Rights Reserved.
3#
4# Licensed under the Apache License 2.0 (the "License").  You may not use
5# this file except in compliance with the License.  You can obtain a copy
6# in the file LICENSE in the source distribution or at
7# https://www.openssl.org/source/license.html
8
9
10use strict;
11use warnings;
12
13use File::Spec;
14use OpenSSL::Test::Utils;
15use OpenSSL::Test qw/:DEFAULT srctop_file/;
16
17setup("test_configutl");
18
19my @tests = qw(escapes.cnf
20leading-and-trailing-whitespace.cnf
21order.cnf
22variables.cnf);
23
24#includes.cnf is temporary excluded as it depends on #27300
25
26plan tests => 2 * (scalar(@tests)) + 1;
27
28require_ok(srctop_file('test', 'recipes', 'tconversion.pl'));
29
30foreach my $file (@tests) {
31    my $path = ($file eq "includes.cnf") ? srctop_file("test", $file) :
32               srctop_file("test", "recipes", "25-test_configutl_data", $file);
33    ok(run(app(["openssl", "configutl",
34       "-config", $path,
35       "-noheader", "-out", "$file.got"])));
36
37    if ($file eq "includes.cnf") {
38        my $cmp1 = cmp_text("$file.got", srctop_file("test", "recipes", "25-test_configutl_data", "$file.expected1"));
39	my $cmp2 = cmp_text("$file.got", srctop_file("test", "recipes", "25-test_configutl_data", "$file.expected2"));
40
41	is((($cmp1 == 0) || ($cmp2 == 0)), 1, "$file got/expected 1/2");
42    } else {
43        is(cmp_text("$file.got",
44           srctop_file("test", "recipes", "25-test_configutl_data", "$file.expected")),
45           0, "$file got/expected");
46    }
47
48    unlink "$file.got";
49}
50