04-test_conf.t 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #! /usr/bin/env perl
  2. # Copyright 2017-2024 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. use strict;
  9. use warnings;
  10. use OpenSSL::Test qw(:DEFAULT data_file);
  11. use OpenSSL::Test::Utils;
  12. use File::Compare qw(compare_text);
  13. setup('test_conf');
  14. my %input_result = (
  15. 'dollarid_on.cnf' => 'dollarid_on.txt',
  16. 'dollarid_off.cnf' => 'dollarid_off.txt',
  17. 'oversized_line.cnf' => 'oversized_line.txt',
  18. );
  19. plan skip_all => 'This is unsupported for cross compiled configurations'
  20. if config('CROSS_COMPILE');
  21. plan tests => 2 * scalar(keys %input_result);
  22. foreach (sort keys %input_result) {
  23. SKIP: {
  24. my $input_path = data_file($_);
  25. my $expected_path = data_file($input_result{$_});
  26. my $result_path = "test_conf-$_-stdout";
  27. skip "Problem dumping $_", 1
  28. unless ok(run(test([ 'confdump', $input_path ],
  29. stdout => $result_path)),
  30. "dumping $_");
  31. is(compare_text($result_path, $expected_path, sub {
  32. my $in1 = $_[0];
  33. my $in2 = $_[1];
  34. $in1 =~ s/\r\n/\n/g;
  35. $in2 =~ s/\r\n/\n/g;
  36. $in1 ne $in2}), 0,
  37. "comparing the dump of $_ with $input_result{$_}");
  38. }
  39. }