]>
git.ipfire.org Git - thirdparty/openssl.git/blob - test/recipes/15-test_out_option.t
2 # Copyright 2018 The OpenSSL Project Authors. All Rights Reserved.
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
14 use OpenSSL
::Test qw
/:DEFAULT srctop_file/;
15 use OpenSSL
::Test
::Utils
;
17 setup
("test_out_option");
23 # Paths that should generate failure when trying to write to them.
24 # Directories are a safe bet for failure on most platforms.
25 # Notably, this isn't true on OpenVMS, as a default file name is
26 # appended under the hood when trying to "write" to a directory spec.
27 # From observation, that file is '.' (i.e. a file with no file name
28 # and no extension), so '[]' gets translated to '[].'
29 skip
'Directories become writable files on OpenVMS', 1 if $^O
eq 'VMS';
31 # Note that directories must end with a slash here, because of how
32 # File::Spec massages them into directory specs on some platforms.
33 my $path = File
::Spec
->canonpath('./');
34 ok
(!run
(app
([ 'openssl', 'rand', '-out', $path, '1'])),
35 "invalid output path: $path");
40 my $path = File
::Spec
->canonpath('randomname.bin');
41 ok
(run
(app
([ 'openssl', 'rand', '-out', $path, '1'])),
42 "valid output path: $path");
47 # Test for trying to create a file in a non-exist directory
50 my @chars = ("A".."Z", "a".."z", "0".."9");
51 $rand_path .= $chars[rand @chars] for 1..32;
52 } while (-d File
::Spec
->catdir('.', $rand_path));
53 $rand_path .= "/randomname.bin";
55 my $path = File
::Spec
->canonpath($rand_path);
56 ok
(!run
(app
([ 'openssl', 'rand', '-out', $path, '1'])),
57 "invalid output path: $path");
62 skip
"It's not safe to use perl's idea of the NULL device in an explicitly cross compiled build", 1
63 unless (config
('CROSS_COMPILE') // '') eq '';
65 my $path = File
::Spec
->canonpath(File
::Spec
->devnull());
66 ok
(run
(app
([ 'openssl', 'rand', '-out', $path, '1'])),
67 "valid output path: $path");
72 unlink 'randomname.bin' if -f
'randomname.bin';