@@ -8,7 +8,7 @@ use crate::common::util::{is_ci, run_ucmd_as_root, TestScenario};
8
8
use filetime:: FileTime ;
9
9
use std:: fs;
10
10
use std:: os:: unix:: fs:: { MetadataExt , PermissionsExt } ;
11
- #[ cfg( not( any ( windows, target_os = "freebsd" ) ) ) ]
11
+ #[ cfg( not( windows) ) ]
12
12
use std:: process:: Command ;
13
13
#[ cfg( any( target_os = "linux" , target_os = "android" ) ) ]
14
14
use std:: thread:: sleep;
@@ -610,13 +610,17 @@ fn test_install_copy_then_compare_file_with_extra_mode() {
610
610
}
611
611
612
612
const STRIP_TARGET_FILE : & str = "helloworld_installed" ;
613
- #[ cfg( not( any ( windows, target_os = "freebsd" ) ) ) ]
613
+ #[ cfg( all ( not( windows) , not ( target_os = "freebsd" ) ) ) ]
614
614
const SYMBOL_DUMP_PROGRAM : & str = "objdump" ;
615
- #[ cfg( not( any( windows, target_os = "freebsd" ) ) ) ]
615
+ #[ cfg( target_os = "freebsd" ) ]
616
+ const SYMBOL_DUMP_PROGRAM : & str = "llvm-objdump" ;
617
+ #[ cfg( not( windows) ) ]
616
618
const STRIP_SOURCE_FILE_SYMBOL : & str = "main" ;
617
619
618
620
fn strip_source_file ( ) -> & ' static str {
619
- if cfg ! ( target_os = "macos" ) {
621
+ if cfg ! ( target_os = "freebsd" ) {
622
+ "helloworld_freebsd"
623
+ } else if cfg ! ( target_os = "macos" ) {
620
624
"helloworld_macos"
621
625
} else if cfg ! ( target_arch = "arm" ) || cfg ! ( target_arch = "aarch64" ) {
622
626
"helloworld_android"
@@ -626,8 +630,7 @@ fn strip_source_file() -> &'static str {
626
630
}
627
631
628
632
#[ test]
629
- // FixME: Freebsd fails on 'No such file or directory'
630
- #[ cfg( not( any( windows, target_os = "freebsd" ) ) ) ]
633
+ #[ cfg( not( windows) ) ]
631
634
fn test_install_and_strip ( ) {
632
635
let scene = TestScenario :: new ( util_name ! ( ) ) ;
633
636
let at = & scene. fixtures ;
@@ -650,8 +653,7 @@ fn test_install_and_strip() {
650
653
}
651
654
652
655
#[ test]
653
- // FixME: Freebsd fails on 'No such file or directory'
654
- #[ cfg( not( any( windows, target_os = "freebsd" ) ) ) ]
656
+ #[ cfg( not( windows) ) ]
655
657
fn test_install_and_strip_with_program ( ) {
656
658
let scene = TestScenario :: new ( util_name ! ( ) ) ;
657
659
let at = & scene. fixtures ;
@@ -677,8 +679,6 @@ fn test_install_and_strip_with_program() {
677
679
678
680
#[ cfg( all( unix, feature = "chmod" ) ) ]
679
681
#[ test]
680
- // FixME: Freebsd fails on 'No such file or directory'
681
- #[ cfg( not( target_os = "freebsd" ) ) ]
682
682
fn test_install_and_strip_with_program_hyphen ( ) {
683
683
let scene = TestScenario :: new ( util_name ! ( ) ) ;
684
684
@@ -715,6 +715,64 @@ fn test_install_and_strip_with_program_hyphen() {
715
715
. stdout_is ( "./-dest\n " ) ;
716
716
}
717
717
718
+ #[ cfg( all( unix, feature = "chmod" ) ) ]
719
+ #[ test]
720
+ fn test_install_on_invalid_link_at_destination ( ) {
721
+ let scene = TestScenario :: new ( util_name ! ( ) ) ;
722
+
723
+ let at = & scene. fixtures ;
724
+ at. mkdir ( "src" ) ;
725
+ at. mkdir ( "dest" ) ;
726
+ let src_dir = at. plus ( "src" ) ;
727
+ let dst_dir = at. plus ( "dest" ) ;
728
+
729
+ at. touch ( "test.sh" ) ;
730
+ at. symlink_file (
731
+ "/opt/FakeDestination" ,
732
+ & dst_dir. join ( "test.sh" ) . to_string_lossy ( ) ,
733
+ ) ;
734
+ scene. ccmd ( "chmod" ) . arg ( "+x" ) . arg ( "test.sh" ) . succeeds ( ) ;
735
+ at. symlink_file ( "test.sh" , & src_dir. join ( "test.sh" ) . to_string_lossy ( ) ) ;
736
+
737
+ scene
738
+ . ucmd ( )
739
+ . current_dir ( & src_dir)
740
+ . arg ( src_dir. join ( "test.sh" ) )
741
+ . arg ( dst_dir. join ( "test.sh" ) )
742
+ . succeeds ( )
743
+ . no_stderr ( )
744
+ . no_stdout ( ) ;
745
+ }
746
+
747
+ #[ cfg( all( unix, feature = "chmod" ) ) ]
748
+ #[ test]
749
+ fn test_install_on_invalid_link_at_destination_and_dev_null_at_source ( ) {
750
+ let scene = TestScenario :: new ( util_name ! ( ) ) ;
751
+
752
+ let at = & scene. fixtures ;
753
+ at. mkdir ( "src" ) ;
754
+ at. mkdir ( "dest" ) ;
755
+ let src_dir = at. plus ( "src" ) ;
756
+ let dst_dir = at. plus ( "dest" ) ;
757
+
758
+ at. touch ( "test.sh" ) ;
759
+ at. symlink_file (
760
+ "/opt/FakeDestination" ,
761
+ & dst_dir. join ( "test.sh" ) . to_string_lossy ( ) ,
762
+ ) ;
763
+ scene. ccmd ( "chmod" ) . arg ( "+x" ) . arg ( "test.sh" ) . succeeds ( ) ;
764
+ at. symlink_file ( "test.sh" , & src_dir. join ( "test.sh" ) . to_string_lossy ( ) ) ;
765
+
766
+ scene
767
+ . ucmd ( )
768
+ . current_dir ( & src_dir)
769
+ . arg ( "/dev/null" )
770
+ . arg ( dst_dir. join ( "test.sh" ) )
771
+ . succeeds ( )
772
+ . no_stderr ( )
773
+ . no_stdout ( ) ;
774
+ }
775
+
718
776
#[ test]
719
777
#[ cfg( not( windows) ) ]
720
778
fn test_install_and_strip_with_invalid_program ( ) {
0 commit comments