"Fossies" - the Fresh Open Source Software Archive 
Member "apache-zookeeper-3.8.1/zookeeper-contrib/zookeeper-contrib-zkperl/t/35_log.t" (25 Jan 2023, 2480 Bytes) of package /linux/misc/apache-zookeeper-3.8.1.tar.gz:
As a special service "Fossies" has tried to format the requested text file into HTML format (style:
standard) with prefixed line numbers.
Alternatively you can here
view or
download the uninterpreted source code file.
See also the last
Fossies "Diffs" side-by-side code changes report for "35_log.t":
3.6.2_vs_3.7.0.
1 # Net::ZooKeeper - Perl extension for Apache ZooKeeper
2 #
3 # Licensed to the Apache Software Foundation (ASF) under one
4 # or more contributor license agreements. See the NOTICE file
5 # distributed with this work for additional information
6 # regarding copyright ownership. The ASF licenses this file
7 # to you under the Apache License, Version 2.0 (the
8 # "License"); you may not use this file except in compliance
9 # with the License. You may obtain a copy of the License at
10 #
11 # http://www.apache.org/licenses/LICENSE-2.0
12 #
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
18
19 use File::Spec;
20 use Test::More tests => 3;
21
22 BEGIN { use_ok('Net::ZooKeeper', qw(:all)) };
23
24
25 my $test_dir;
26 (undef, $test_dir, undef) = File::Spec->splitpath($0);
27 require File::Spec->catfile($test_dir, 'util.pl');
28
29 my($hosts, $root_path, $node_path) = zk_test_setup(0);
30
31
32 my $zkh = Net::ZooKeeper->new($hosts);
33
34 Net::ZooKeeper::set_log_level(ZOO_LOG_LEVEL_DEBUG);
35
36 SKIP: {
37 skip 'no valid handle', 2 unless (defined($zkh));
38
39 SKIP: {
40 my $dup = 0;
41
42 if (open(OLDERR, '>&', fileno(STDERR))) {
43 if (close(STDERR) and open(STDERR, '+>', undef)) {
44 $dup = 1;
45
46 my $old_select = select(STDERR);
47 $| = 1;
48 $/ = undef; # slurp mode.
49 select($old_select);
50 }
51 else {
52 open(STDERR, '>&', fileno(OLDERR));
53 close(OLDERR);
54 }
55 }
56
57 skip 'no duplicated stderr', 2 unless ($dup);
58
59 SKIP: {
60 $zkh->exists($root_path);
61
62 sleep(1);
63
64 skip 'no seek on stderr', 1 unless (seek(STDERR, 0, 0));
65
66 my $log = <STDERR>;
67 like($log, qr/ZOO_.*exists/,
68 'exists(): generated log message');
69 }
70
71 SKIP: {
72 $zkh->DESTROY();
73
74 sleep(1);
75
76 skip 'no seek on stderr', 1 unless (seek(STDERR, 0, 0));
77
78 my $log = <STDERR>;
79 like($log, qr/ZOO_.*close/,
80 'DESTROY(): generated log message');
81 }
82
83 open(STDERR, '>&', fileno(OLDERR));
84 close(OLDERR);
85 }
86 }
87
88 Net::ZooKeeper::set_log_level(ZOO_LOG_LEVEL_OFF);
89