@@ -966,11 +966,101 @@ str2jobflags(Pool *pool, char *s) /* modifies the string */
966966 return jobflags ;
967967}
968968
969+ static Id
970+ testcase_str2jobsel (Pool * pool , const char * caller , char * * pieces , int npieces , Id * whatp )
971+ {
972+ Id job , what ;
973+ if (!strcmp (pieces [0 ], "pkg" ) && npieces == 2 )
974+ {
975+ job = SOLVER_SOLVABLE ;
976+ what = testcase_str2solvid (pool , pieces [1 ]);
977+ if (!what )
978+ return pool_error (pool , -1 , "%s: unknown package '%s'" , caller , pieces [1 ]);
979+ }
980+ else if (!strcmp (pieces [0 ], "name" ) || !strcmp (pieces [0 ], "provides" ))
981+ {
982+ /* join em again for dep2str... */
983+ char * sp ;
984+ for (sp = pieces [1 ]; sp < pieces [npieces - 1 ]; sp ++ )
985+ if (* sp == 0 )
986+ * sp = ' ' ;
987+ what = 0 ;
988+ if (pieces [0 ][0 ] == 'p' && strncmp (pieces [1 ], "namespace:" , 10 ) == 0 )
989+ {
990+ char * spe = strchr (pieces [1 ], '(' );
991+ int l = strlen (pieces [1 ]);
992+ if (spe && pieces [1 ][l - 1 ] == ')' )
993+ {
994+ /* special namespace provides */
995+ if (strcmp (spe , "(<NULL>)" ) != 0 )
996+ {
997+ pieces [1 ][l - 1 ] = 0 ;
998+ what = testcase_str2dep (pool , spe + 1 );
999+ pieces [1 ][l - 1 ] = ')' ;
1000+ }
1001+ what = pool_rel2id (pool , pool_strn2id (pool , pieces [1 ], spe - pieces [1 ], 1 ), what , REL_NAMESPACE , 1 );
1002+ }
1003+ }
1004+ if (!what )
1005+ what = testcase_str2dep (pool , pieces [1 ]);
1006+ if (pieces [0 ][0 ] == 'n' )
1007+ job = SOLVER_SOLVABLE_NAME ;
1008+ else
1009+ job = SOLVER_SOLVABLE_PROVIDES ;
1010+ }
1011+ else if (!strcmp (pieces [0 ], "oneof" ))
1012+ {
1013+ Queue q ;
1014+ job = SOLVER_SOLVABLE_ONE_OF ;
1015+ queue_init (& q );
1016+ if (npieces > 1 && strcmp (pieces [1 ], "nothing" ) != 0 )
1017+ {
1018+ int i ;
1019+ for (i = 1 ; i < npieces ; i ++ )
1020+ {
1021+ Id p = testcase_str2solvid (pool , pieces [i ]);
1022+ if (!p )
1023+ {
1024+ queue_free (& q );
1025+ return pool_error (pool , -1 , "%s: unknown package '%s'" , caller , pieces [i ]);
1026+ }
1027+ queue_push (& q , p );
1028+ }
1029+ }
1030+ what = pool_queuetowhatprovides (pool , & q );
1031+ queue_free (& q );
1032+ }
1033+ else if (!strcmp (pieces [0 ], "repo" ) && npieces == 2 )
1034+ {
1035+ Repo * repo = testcase_str2repo (pool , pieces [1 ]);
1036+ if (!repo )
1037+ return pool_error (pool , -1 , "%s: unknown repo '%s'" , caller , pieces [1 ]);
1038+ job = SOLVER_SOLVABLE_REPO ;
1039+ what = repo -> repoid ;
1040+ }
1041+ else if (!strcmp (pieces [0 ], "all" ) && npieces == 2 && !strcmp (pieces [1 ], "packages" ))
1042+ {
1043+ job = SOLVER_SOLVABLE_ALL ;
1044+ what = 0 ;
1045+ }
1046+ else
1047+ {
1048+ /* join em again for the error message... */
1049+ char * sp ;
1050+ for (sp = pieces [0 ]; sp < pieces [npieces - 1 ]; sp ++ )
1051+ if (* sp == 0 )
1052+ * sp = ' ' ;
1053+ return pool_error (pool , -1 , "%s: bad line '%s'" , caller , pieces [0 ]);
1054+ }
1055+ * whatp = what ;
1056+ return job ;
1057+ }
1058+
9691059Id
9701060testcase_str2job (Pool * pool , const char * str , Id * whatp )
9711061{
9721062 int i ;
973- Id job ;
1063+ Id job , jobsel ;
9741064 Id what ;
9751065 char * s ;
9761066 char * * pieces = 0 ;
@@ -1022,116 +1112,12 @@ testcase_str2job(Pool *pool, const char *str, Id *whatp)
10221112 job |= str2jobflags (pool , flags );
10231113 }
10241114 }
1025- if (!strcmp (pieces [1 ], "pkg" ))
1026- {
1027- if (npieces != 3 )
1028- {
1029- pool_error (pool , -1 , "str2job: bad pkg selector in '%s'" , str );
1030- solv_free (pieces );
1031- return -1 ;
1032- }
1033- job |= SOLVER_SOLVABLE ;
1034- what = testcase_str2solvid (pool , pieces [2 ]);
1035- if (!what )
1036- {
1037- pool_error (pool , -1 , "str2job: unknown package '%s'" , pieces [2 ]);
1038- solv_free (pieces );
1039- return -1 ;
1040- }
1041- }
1042- else if (!strcmp (pieces [1 ], "name" ) || !strcmp (pieces [1 ], "provides" ))
1043- {
1044- /* join em again for dep2str... */
1045- char * sp ;
1046- for (sp = pieces [2 ]; sp < pieces [npieces - 1 ]; sp ++ )
1047- if (* sp == 0 )
1048- * sp = ' ' ;
1049- what = 0 ;
1050- if (pieces [1 ][0 ] == 'p' && strncmp (pieces [2 ], "namespace:" , 10 ) == 0 )
1051- {
1052- char * spe = strchr (pieces [2 ], '(' );
1053- int l = strlen (pieces [2 ]);
1054- if (spe && pieces [2 ][l - 1 ] == ')' )
1055- {
1056- /* special namespace provides */
1057- if (strcmp (spe , "(<NULL>)" ) != 0 )
1058- {
1059- pieces [2 ][l - 1 ] = 0 ;
1060- what = testcase_str2dep (pool , spe + 1 );
1061- pieces [2 ][l - 1 ] = ')' ;
1062- }
1063- what = pool_rel2id (pool , pool_strn2id (pool , pieces [2 ], spe - pieces [2 ], 1 ), what , REL_NAMESPACE , 1 );
1064- }
1065- }
1066- if (!what )
1067- what = testcase_str2dep (pool , pieces [2 ]);
1068- if (pieces [1 ][0 ] == 'n' )
1069- job |= SOLVER_SOLVABLE_NAME ;
1070- else
1071- job |= SOLVER_SOLVABLE_PROVIDES ;
1072- }
1073- else if (!strcmp (pieces [1 ], "oneof" ))
1074- {
1075- Queue q ;
1076- job |= SOLVER_SOLVABLE_ONE_OF ;
1077- queue_init (& q );
1078- if (npieces > 2 && strcmp (pieces [2 ], "nothing" ) != 0 )
1079- {
1080- for (i = 2 ; i < npieces ; i ++ )
1081- {
1082- Id p = testcase_str2solvid (pool , pieces [i ]);
1083- if (!p )
1084- {
1085- pool_error (pool , -1 , "str2job: unknown package '%s'" , pieces [i ]);
1086- queue_free (& q );
1087- solv_free (pieces );
1088- return -1 ;
1089- }
1090- queue_push (& q , p );
1091- }
1092- }
1093- what = pool_queuetowhatprovides (pool , & q );
1094- queue_free (& q );
1095- }
1096- else if (!strcmp (pieces [1 ], "repo" ))
1097- {
1098- Repo * repo ;
1099- if (npieces != 3 )
1100- {
1101- pool_error (pool , -1 , "str2job: bad line '%s'" , str );
1102- solv_free (pieces );
1103- return -1 ;
1104- }
1105- repo = testcase_str2repo (pool , pieces [2 ]);
1106- if (!repo )
1107- {
1108- pool_error (pool , -1 , "str2job: unknown repo '%s'" , pieces [2 ]);
1109- solv_free (pieces );
1110- return -1 ;
1111- }
1112- job |= SOLVER_SOLVABLE_REPO ;
1113- what = repo -> repoid ;
1114- }
1115- else if (!strcmp (pieces [1 ], "all" ))
1116- {
1117- if (npieces != 3 && strcmp (pieces [2 ], "packages" ) != 0 )
1118- {
1119- pool_error (pool , -1 , "str2job: bad line '%s'" , str );
1120- solv_free (pieces );
1121- return -1 ;
1122- }
1123- job |= SOLVER_SOLVABLE_ALL ;
1124- what = 0 ;
1125- }
1126- else
1127- {
1128- pool_error (pool , -1 , "str2job: unknown selection in '%s'" , str );
1129- solv_free (pieces );
1130- return -1 ;
1131- }
1132- * whatp = what ;
1115+ jobsel = testcase_str2jobsel (pool , "str2job" , pieces + 1 , npieces - 1 , & what );
11331116 solv_free (pieces );
1134- return job ;
1117+ if (jobsel == -1 )
1118+ return -1 ;
1119+ * whatp = what ;
1120+ return job | jobsel ;
11351121}
11361122
11371123#define SELECTIONJOB_MATCHDEPS 1
@@ -2881,12 +2867,7 @@ testcase_read(Pool *pool, FILE *fp, const char *testcase, Queue *job, char **res
28812867 }
28822868 else if (!strcmp (pieces [0 ], "disable" ) && npieces == 3 )
28832869 {
2884- Id p ;
2885- if (strcmp (pieces [1 ], "pkg" ))
2886- {
2887- pool_error (pool , 0 , "testcase_read: bad disable type '%s'" , pieces [1 ]);
2888- continue ;
2889- }
2870+ Id p , pp , jobsel , what = 0 ;
28902871 if (!prepared )
28912872 pool_createwhatprovides (pool );
28922873 prepared = -1 ;
@@ -2896,11 +2877,20 @@ testcase_read(Pool *pool, FILE *fp, const char *testcase, Queue *job, char **res
28962877 map_init (pool -> considered , pool -> nsolvables );
28972878 map_setall (pool -> considered );
28982879 }
2899- p = testcase_str2solvid (pool , pieces [2 ]);
2900- if (p )
2880+ jobsel = testcase_str2jobsel (pool , "disable" , pieces + 1 , npieces - 1 , & what );
2881+ if (jobsel < 0 )
2882+ continue ;
2883+ if (jobsel == SOLVER_SOLVABLE_ALL )
2884+ map_empty (pool -> considered );
2885+ else if (jobsel == SOLVER_SOLVABLE_REPO )
2886+ {
2887+ Repo * repo = pool_id2repo (pool , what );
2888+ Solvable * s ;
2889+ FOR_REPO_SOLVABLES (repo , p , s )
2890+ MAPCLR (pool -> considered , p );
2891+ }
2892+ FOR_JOB_SELECT (p , pp , jobsel , what )
29012893 MAPCLR (pool -> considered , p );
2902- else
2903- pool_error (pool , 0 , "disable: unknown package '%s'" , pieces [2 ]);
29042894 }
29052895 else if (!strcmp (pieces [0 ], "feature" ))
29062896 {
0 commit comments