Changeset View
Changeset View
Standalone View
Standalone View
lib/libc/tests/stdlib/qsort_r_compat_test.c
- This file was copied from lib/libc/tests/stdlib/qsort_r_test.c.
Show All 20 Lines | |||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
* SUCH DAMAGE. | * SUCH DAMAGE. | ||||
*/ | */ | ||||
/* | /* | ||||
* Test for qsort_r(3) routine. | * Test for historical qsort_r(3) routine. | ||||
*/ | */ | ||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include <stdio.h> | #include <stdio.h> | ||||
#include <stdlib.h> | #include <stdlib.h> | ||||
Show All 13 Lines | sorthelp_r(void *thunk, const void *a, const void *b) | ||||
/* Don't use "return *oa - *ob" since it's easy to cause overflow! */ | /* Don't use "return *oa - *ob" since it's easy to cause overflow! */ | ||||
if (*oa > *ob) | if (*oa > *ob) | ||||
return (1); | return (1); | ||||
if (*oa < *ob) | if (*oa < *ob) | ||||
return (-1); | return (-1); | ||||
return (0); | return (0); | ||||
} | } | ||||
ATF_TC_WITHOUT_HEAD(qsort_r_test); | ATF_TC_WITHOUT_HEAD(qsort_r_compat_test); | ||||
ATF_TC_BODY(qsort_r_test, tc) | ATF_TC_BODY(qsort_r_compat_test, tc) | ||||
{ | { | ||||
int testvector[IVEC_LEN]; | int testvector[IVEC_LEN]; | ||||
int sresvector[IVEC_LEN]; | int sresvector[IVEC_LEN]; | ||||
int i, j; | int i, j; | ||||
int thunk = THUNK; | int thunk = THUNK; | ||||
for (j = 2; j < IVEC_LEN; j++) { | for (j = 2; j < IVEC_LEN; j++) { | ||||
/* Populate test vectors */ | /* Populate test vectors */ | ||||
Show All 12 Lines | for (i = 0; i < j; i++) | ||||
"item at index %d didn't match: %d != %d", | "item at index %d didn't match: %d != %d", | ||||
i, testvector[i], sresvector[i]); | i, testvector[i], sresvector[i]); | ||||
} | } | ||||
} | } | ||||
ATF_TP_ADD_TCS(tp) | ATF_TP_ADD_TCS(tp) | ||||
{ | { | ||||
ATF_TP_ADD_TC(tp, qsort_r_test); | ATF_TP_ADD_TC(tp, qsort_r_compat_test); | ||||
return (atf_no_error()); | return (atf_no_error()); | ||||
} | } |