If we request more than 9 chips for a test case, we'll run into
a problem: 'gpiochip10' will come before 'gpiochip2' when sorting by
name.
Sort by chip number instead - it's stored as an unsigned integer and
the above situation will not occur.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
const struct mockup_chip *chip1 = *(const struct mockup_chip **)c1;
const struct mockup_chip *chip2 = *(const struct mockup_chip **)c2;
- return strcmp(chip1->name, chip2->name);
+ return chip1->number > chip2->number;
}
static bool devpath_is_mockup(const char *devpath)
* order in which the chips were defined in the GU_DEFINE_TEST()
* macro.
*
- * Once all gpiochips are there, sort them by name.
+ * Once all gpiochips are there, sort them by chip number.
*/
qsort(ctx->chips, ctx->num_chips, sizeof(*ctx->chips), chipcmp);
}