2 # Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
4 # Licensed under the OpenSSL license (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
13 use File::Spec::Functions;
16 use OpenSSL::Test qw/:DEFAULT bldtop_file/;
20 #If "openssl rehash -help" fails it's most likely because we're on a platform
21 #that doesn't support the rehash command (e.g. Windows)
22 plan skip_all => "test_rehash is not available on this platform"
23 unless run(app(["openssl", "rehash", "-help"]));
27 indir "rehash.$$" => sub {
29 ok(run(app(["openssl", "rehash", curdir()])),
30 'Testing normal rehash operations');
31 }, create => 1, cleanup => 1;
33 indir "rehash.$$" => sub {
34 prepare(sub { chmod 400, $_ foreach (@_); });
35 ok(run(app(["openssl", "rehash", curdir()])),
36 'Testing rehash operations on readonly files');
37 }, create => 1, cleanup => 1;
39 indir "rehash.$$" => sub {
40 ok(run(app(["openssl", "rehash", curdir()])),
41 'Testing rehash operations on empty directory');
42 }, create => 1, cleanup => 1;
44 indir "rehash.$$" => sub {
48 if (!ok(!open(FOO, ">unwritable.txt"),
49 "Testing that we aren't running as a privileged user, such as root")) {
51 skip "It's pointless to run the next test as root", 1;
53 isnt(run(app(["openssl", "rehash", curdir()])), 1,
54 'Testing rehash operations on readonly directory');
56 chmod 0700, curdir(); # make it writable again, so cleanup works
57 }, create => 1, cleanup => 1;
61 sort map { glob(bldtop_file('certs', 'demo', "*.$_")) } ('pem',
66 foreach (@sourcefiles) {
68 push @destfiles, catfile(curdir(), basename($_));
71 die "Internal error, argument is not CODE"
72 unless (ref($_) eq 'CODE');