@@ -2591,6 +2591,60 @@ def test_EACCES
25912591 d . instance_shutdown if d && d . instance
25922592 end
25932593
2594+ def test_warn_without_directory_permission
2595+ omit "Cannot test with root user" if Process ::UID . eid == 0
2596+ path = "#{ @tmp_dir } /noaccess/tail.txt"
2597+ begin
2598+ FileUtils . mkdir_p ( "#{ @tmp_dir } /noaccess" )
2599+ FileUtils . touch ( path )
2600+ FileUtils . chmod ( 0400 , path )
2601+ FileUtils . chmod ( 0600 , "#{ @tmp_dir } /noaccess" )
2602+ config = config_element ( '' , '' , {
2603+ 'tag' => "tail" ,
2604+ 'path' => path ,
2605+ 'format' => 'none' ,
2606+ "pos_file" => "#{ @tmp_dir } /tail.pos" ,
2607+ } )
2608+ d = create_driver ( config , false )
2609+ assert_nothing_raised do
2610+ d . run ( shutdown : false ) { }
2611+ end
2612+ assert ( $log. out . logs . any? { |log | log . include? ( "Skip #{ path } because a directory in the path lacks execute permission.\n " ) } )
2613+ end
2614+ ensure
2615+ d . instance_shutdown if d && d . instance
2616+ FileUtils . chmod ( 0755 , "#{ @tmp_dir } /noaccess" )
2617+ if File . exist? ( "#{ @tmp_dir } /noaccess" )
2618+ FileUtils . rm_rf ( "#{ @tmp_dir } /noaccess" )
2619+ end
2620+ end unless Fluent . windows?
2621+
2622+ def test_no_warn_with_directory_permission
2623+ omit "Cannot test with root user" if Process ::UID . eid == 0
2624+ path = "#{ @tmp_dir } /noaccess/tail.txt"
2625+ begin
2626+ FileUtils . mkdir_p ( "#{ @tmp_dir } /noaccess" )
2627+ FileUtils . chmod ( 0100 , "#{ @tmp_dir } /noaccess" )
2628+ config = config_element ( '' , '' , {
2629+ 'tag' => "tail" ,
2630+ 'path' => path ,
2631+ 'format' => 'none' ,
2632+ "pos_file" => "#{ @tmp_dir } /tail.pos" ,
2633+ } )
2634+ d = create_driver ( config , false )
2635+ assert_nothing_raised do
2636+ d . run ( shutdown : false ) { }
2637+ end
2638+ assert ( $log. out . logs . all? { |log | !log . include? ( "Skip #{ path } because a directory in the path lacks execute permission.\n " ) } )
2639+ end
2640+ ensure
2641+ d . instance_shutdown if d && d . instance
2642+ FileUtils . chmod ( 0755 , "#{ @tmp_dir } /noaccess" )
2643+ if File . exist? ( "#{ @tmp_dir } /noaccess" )
2644+ FileUtils . rm_rf ( "#{ @tmp_dir } /noaccess" )
2645+ end
2646+ end unless Fluent . windows?
2647+
25942648 def test_shutdown_timeout
25952649 Fluent ::FileWrapper . open ( "#{ @tmp_dir } /tail.txt" , "wb" ) do |f |
25962650 # Should be large enough to take too long time to consume
0 commit comments