30bdd695250eeecbf0b36c1e3c90d67ca03953edLennart Poettering This file is part of systemd.
30bdd695250eeecbf0b36c1e3c90d67ca03953edLennart Poettering Copyright 2013 Lennart Poettering
30bdd695250eeecbf0b36c1e3c90d67ca03953edLennart Poettering systemd is free software; you can redistribute it and/or modify it
30bdd695250eeecbf0b36c1e3c90d67ca03953edLennart Poettering under the terms of the GNU Lesser General Public License as published by
30bdd695250eeecbf0b36c1e3c90d67ca03953edLennart Poettering the Free Software Foundation; either version 2.1 of the License, or
30bdd695250eeecbf0b36c1e3c90d67ca03953edLennart Poettering (at your option) any later version.
30bdd695250eeecbf0b36c1e3c90d67ca03953edLennart Poettering systemd is distributed in the hope that it will be useful, but
30bdd695250eeecbf0b36c1e3c90d67ca03953edLennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
30bdd695250eeecbf0b36c1e3c90d67ca03953edLennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30bdd695250eeecbf0b36c1e3c90d67ca03953edLennart Poettering Lesser General Public License for more details.
30bdd695250eeecbf0b36c1e3c90d67ca03953edLennart Poettering You should have received a copy of the GNU Lesser General Public License
30bdd695250eeecbf0b36c1e3c90d67ca03953edLennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
30bdd695250eeecbf0b36c1e3c90d67ca03953edLennart Poetteringstatic int unsigned_compare(const void *a, const void *b) {
30bdd695250eeecbf0b36c1e3c90d67ca03953edLennart Poettering const unsigned *x = a, *y = b;
30bdd695250eeecbf0b36c1e3c90d67ca03953edLennart Poettering for (i = 0; i < ELEMENTSOF(buffer); i++) {
30bdd695250eeecbf0b36c1e3c90d67ca03953edLennart Poettering u = (unsigned) rand();
30bdd695250eeecbf0b36c1e3c90d67ca03953edLennart Poettering assert_se(prioq_put(q, UINT_TO_PTR(u), NULL) >= 0);
30bdd695250eeecbf0b36c1e3c90d67ca03953edLennart Poettering qsort(buffer, ELEMENTSOF(buffer), sizeof(buffer[0]), unsigned_compare);
30bdd695250eeecbf0b36c1e3c90d67ca03953edLennart Poettering for (i = 0; i < ELEMENTSOF(buffer); i++) {
30bdd695250eeecbf0b36c1e3c90d67ca03953edLennart Poettering assert_se(prioq_size(q) == ELEMENTSOF(buffer) - i);
30bdd695250eeecbf0b36c1e3c90d67ca03953edLennart Poetteringstatic int test_compare(const void *a, const void *b) {
30bdd695250eeecbf0b36c1e3c90d67ca03953edLennart Poettering const struct test *x = a, *y = b;
b826ab586c9e0a9c0d438a75c28cf3a8ab485929Tom Gundersenstatic void test_hash(const void *a, struct siphash *state) {
30bdd695250eeecbf0b36c1e3c90d67ca03953edLennart Poettering const struct test *x = a;
b826ab586c9e0a9c0d438a75c28cf3a8ab485929Tom Gundersen siphash24_compress(&x->value, sizeof(x->value), state);
d5099efc47d4e6ac60816b5381a5f607ab03f06eMichal Schmidtstatic const struct hash_ops test_hash_ops = {
30bdd695250eeecbf0b36c1e3c90d67ca03953edLennart Poettering for (i = 0; i < SET_SIZE; i++) {
30bdd695250eeecbf0b36c1e3c90d67ca03953edLennart Poettering if (i % 4 == 0) {
30bdd695250eeecbf0b36c1e3c90d67ca03953edLennart Poettering assert_se(prioq_size(q) == (SET_SIZE * 3 / 4) - i);