@@ -1130,4 +1130,71 @@ mod tests {
1130
1130
assert_eq ! ( tcd. is_tracking( ) , case. 1 ) ;
1131
1131
}
1132
1132
}
1133
+
1134
+ #[ test]
1135
+ fn compatible_host_triples ( ) {
1136
+ static CASES : & [ ( & str , & [ & str ] , & [ & str ] ) ] = & [
1137
+ (
1138
+ // 64bit linux
1139
+ "x86_64-unknown-linux-gnu" ,
1140
+ // Not compatible beyond itself
1141
+ & [ ] ,
1142
+ // Even 32bit linux is considered not compatible by default
1143
+ & [ "i686-unknown-linux-gnu" ] ,
1144
+ ) ,
1145
+ (
1146
+ // On the other hand, 64 bit Windows
1147
+ "x86_64-pc-windows-msvc" ,
1148
+ // is compatible with 32 bit windows, and even gnu
1149
+ & [
1150
+ "i686-pc-windows-msvc" ,
1151
+ "x86_64-pc-windows-gnu" ,
1152
+ "i686-pc-windows-gnu" ,
1153
+ ] ,
1154
+ // But is not compatible with Linux
1155
+ & [ "x86_64-unknown-linux-gnu" ] ,
1156
+ ) ,
1157
+ (
1158
+ // Indeed, 64bit windows with the gnu toolchain
1159
+ "x86_64-pc-windows-gnu" ,
1160
+ // is compatible with the other windows platforms
1161
+ & [
1162
+ "i686-pc-windows-msvc" ,
1163
+ "x86_64-pc-windows-gnu" ,
1164
+ "i686-pc-windows-gnu" ,
1165
+ ] ,
1166
+ // But is not compatible with Linux despite also being gnu
1167
+ & [ "x86_64-unknown-linux-gnu" ] ,
1168
+ ) ,
1169
+ (
1170
+ // However, 32bit Windows is not expected to be able to run
1171
+ // 64bit windows
1172
+ "i686-pc-windows-msvc" ,
1173
+ & [ "i686-pc-windows-gnu" ] ,
1174
+ & [ "x86_64-pc-windows-msvc" , "x86_64-pc-windows-gnu" ] ,
1175
+ ) ,
1176
+ ] ;
1177
+
1178
+ for ( host, compatible, incompatible) in CASES {
1179
+ println ! ( "host={}" , host) ;
1180
+ let host = TargetTriple :: new ( host) ;
1181
+ assert ! ( host. can_run( & host) . unwrap( ) , "host wasn't self-compatible" ) ;
1182
+ for other in compatible. iter ( ) {
1183
+ println ! ( "compatible with {}" , other) ;
1184
+ let other = TargetTriple :: new ( other) ;
1185
+ assert ! (
1186
+ host. can_run( & other) . unwrap( ) ,
1187
+ "host and other were unexpectedly incompatible"
1188
+ ) ;
1189
+ }
1190
+ for other in incompatible. iter ( ) {
1191
+ println ! ( "incompatible with {}" , other) ;
1192
+ let other = TargetTriple :: new ( other) ;
1193
+ assert ! (
1194
+ !host. can_run( & other) . unwrap( ) ,
1195
+ "host and other were unexpectedly compatible"
1196
+ ) ;
1197
+ }
1198
+ }
1199
+ }
1133
1200
}
0 commit comments