first and last commit
This commit is contained in:
commit
1bf4efd552
2612 files changed
+636500
No files matched your search
@@ -0,0 +1,203 @@
|
||||
/*
|
||||
* Copyright (C) 2011-2012, 2014 Apple Inc. All rights reserved.
|
||||
*
|
||||
* This document is the property of Apple Inc.
|
||||
* It is considered confidential and proprietary.
|
||||
*
|
||||
* This document may not be reproduced or transmitted in any form,
|
||||
* in whole or in part, without the express written permission of
|
||||
* Apple Inc.
|
||||
*/
|
||||
|
||||
#ifdef __arm__
|
||||
|
||||
.text
|
||||
.syntax unified
|
||||
|
||||
.text
|
||||
.align 2
|
||||
|
||||
#define N 4096 /* size of ring buffer - must be power of 2 */
|
||||
#define F 18 /* upper limit for match_length */
|
||||
#define THRESHOLD 2 /* encode string into position and length if match_length is greater than this */
|
||||
|
||||
.globl _decompress_lzss_vec
|
||||
_decompress_lzss_vec:
|
||||
|
||||
// int decompress_lzss(
|
||||
// u_int8_t * dst, - r0
|
||||
// u_int32_t dstlen, - r1 never used
|
||||
// u_int8_t * src, - r2
|
||||
// u_int32_t srclen) - r3 (used once to define srcend)
|
||||
// {
|
||||
// u_int8_t text_buf[N + F - 1];
|
||||
// u_int8_t * dststart = dst;
|
||||
// const u_int8_t * srcend = src + srclen;
|
||||
// int i, j, k, r, c;
|
||||
// unsigned int flags;
|
||||
|
||||
// dst = dststart;
|
||||
|
||||
mov r12, r0
|
||||
|
||||
// for (i = 0; i < N - F; i++) text_buf[i] = ' ';
|
||||
|
||||
push {r4-r8,r10-r11,lr}
|
||||
|
||||
mov lr, sp // store sp in lr, need to aligned
|
||||
mov r4, #0xfffffff0
|
||||
and sp, r4 // 16-byte alignment
|
||||
|
||||
mov r5, #32 // r5 = ' ';
|
||||
sub sp, #N // it appears that text_buf[N] is sufficient, the extra F-1 bytes is never used
|
||||
|
||||
add r5, r5, r5, lsl #8 // r5 = ' ';
|
||||
mov r4, sp // r1 -> text_buf[0]
|
||||
add r5, r5, r5, lsl #16 // r5 = ' ';
|
||||
|
||||
mov r1, #(N-F+2) // do extra 2, so that 4080 is a multiple of 16 (255)
|
||||
|
||||
#if WITH_VFP
|
||||
vdup.32 q0, r5
|
||||
#else
|
||||
mov r6, r5
|
||||
mov r7, r5
|
||||
mov r8, r5
|
||||
#endif
|
||||
|
||||
loop0:
|
||||
#if WITH_VFP
|
||||
vst1.f32 {q0}, [r4,:128]!
|
||||
#else
|
||||
stmia r4!, {r5-r8}
|
||||
#endif
|
||||
subs r1, #16
|
||||
bgt loop0
|
||||
|
||||
// r = N - F;
|
||||
// flags = 0;
|
||||
|
||||
|
||||
mov r4, #N
|
||||
sub r11, r4, #1 // r11 = N-1, will be used for circular buffering in text_buf[r]
|
||||
sub r4, #F // r = N-r
|
||||
mov r1, #0 // flag = 0
|
||||
|
||||
#define dststart r12
|
||||
#define dst r0
|
||||
#define flags r1
|
||||
#define src r2
|
||||
#define srcend r3
|
||||
#define r r4
|
||||
#define c r5
|
||||
#define i r6
|
||||
#define j r7
|
||||
#define t r8
|
||||
#define k r10
|
||||
#define text_buf sp
|
||||
#define Nm1 r11
|
||||
|
||||
add srcend, src, r3
|
||||
|
||||
for_loop:
|
||||
|
||||
// for ( ; ; ) {
|
||||
|
||||
// if (((flags >>= 1) & 0x100) == 0) {
|
||||
// if (src < srcend) c = *src++; else break;
|
||||
// flags = c | 0xFF00;
|
||||
// }
|
||||
|
||||
lsr flags, #1 // flags >>= 1
|
||||
tst flags, #0x100 // (flags >>= 1) & 0x100)
|
||||
bne skip1 // if != 0, skip the following
|
||||
cmp src, srcend // src vs srcend
|
||||
bge break_for_loop // if (src>=srcend) break_for_loop
|
||||
ldrb c,[src],#1 // c = *src++
|
||||
orr flags,c,#0x00ff00 // flags = c | 0xFF00;
|
||||
|
||||
skip1:
|
||||
|
||||
// if (flags & 1) {
|
||||
tst flags, #1
|
||||
beq skip2
|
||||
// if (src < srcend) c = *src++; else break;
|
||||
// *dst++ = c;
|
||||
// text_buf[r++] = c;
|
||||
// r &= (N - 1);
|
||||
|
||||
cmp src, srcend // src vs srcend
|
||||
bge break_for_loop // if (src>=srcend) break_for_loop
|
||||
ldrb c,[src],#1 // c = *src++
|
||||
strb c,[text_buf,r] // text_buf[r]
|
||||
add r, #1 // r++
|
||||
strb c,[dst],#1 // *dst++ = c;
|
||||
and r, Nm1 // r &= (N - 1);
|
||||
b for_loop
|
||||
|
||||
// } else {
|
||||
skip2:
|
||||
// if (src < srcend) i = *src++; else break;
|
||||
// if (src < srcend) j = *src++; else break;
|
||||
|
||||
#if (0)
|
||||
cmp src, srcend // src vs srcend
|
||||
bge break_for_loop // if (src>=srcend) break_for_loop
|
||||
ldrb i,[src],#1 // i = *src++
|
||||
cmp src, srcend // src vs srcend
|
||||
bge break_for_loop // if (src>=srcend) break_for_loop
|
||||
ldrb j,[src],#1 // j = *src++
|
||||
#else
|
||||
ldrh i,[src],#2 //
|
||||
cmp src, srcend //
|
||||
lsr j, i, #8
|
||||
bgt break_for_loop
|
||||
sub i, i, j, lsl #8
|
||||
|
||||
#endif
|
||||
|
||||
// i |= ((j & 0xF0) << 4);
|
||||
// j = (j & 0x0F) + THRESHOLD;
|
||||
|
||||
and t, j, #0xf0 // j&0xf0
|
||||
and j, #0x0f // j&0x0f
|
||||
orr i, i, t, lsl #4 // i |= ((j & 0xF0) << 4);
|
||||
add j, #THRESHOLD // j = (j & 0x0F) + THRESHOLD;
|
||||
|
||||
// for (k = 0; k <= j; k++) {
|
||||
// c = text_buf[(i + k) & (N - 1)];
|
||||
// *dst++ = c;
|
||||
// text_buf[r++] = c;
|
||||
// r &= (N - 1);
|
||||
// }
|
||||
mov k, #0
|
||||
|
||||
k_loop:
|
||||
add t, i, k // (i+k)
|
||||
and t, Nm1 // (i + k) & (N - 1)
|
||||
ldrb c, [text_buf, t] // c = text_buf[(i + k) & (N - 1)];
|
||||
strb c, [dst], #1 // *dst++ = c;
|
||||
strb c, [text_buf, r] // text_buf[r] = c;
|
||||
add r, #1 // r++
|
||||
and r, Nm1 // r &= (N - 1);
|
||||
add k, #1 // k++
|
||||
cmp k, j // k vs j
|
||||
ble k_loop
|
||||
b for_loop
|
||||
|
||||
// }
|
||||
// }
|
||||
|
||||
break_for_loop:
|
||||
sub dst, dststart
|
||||
|
||||
mov sp, lr // lr stores sp before 16-byte alignment
|
||||
pop {r4-r8,r10-r11,pc}
|
||||
|
||||
|
||||
|
||||
// return dst - dststart;
|
||||
// }
|
||||
|
||||
#endif // __arm__
|
||||
|
||||
@@ -0,0 +1,179 @@
|
||||
/*
|
||||
* Copyright (C) 2013-2014 Apple Inc. All rights reserved.
|
||||
*
|
||||
* This document is the property of Apple Inc.
|
||||
* It is considered confidential and proprietary.
|
||||
*
|
||||
* This document may not be reproduced or transmitted in any form,
|
||||
* in whole or in part, without the express written permission of
|
||||
* Apple Inc.
|
||||
*/
|
||||
|
||||
#ifdef __arm64__
|
||||
|
||||
.text
|
||||
.align 2
|
||||
|
||||
#define N 4096 /* size of ring buffer - must be power of 2 */
|
||||
#define F 18 /* upper limit for match_length */
|
||||
#define THRESHOLD 2 /* encode string into position and length if match_length is greater than this */
|
||||
|
||||
.globl _decompress_lzss_vec
|
||||
_decompress_lzss_vec:
|
||||
|
||||
// int decompress_lzss(
|
||||
// u_int8_t * dst, - x0
|
||||
// u_int32_t dstlen, - x1 never used
|
||||
// u_int8_t * src, - x2
|
||||
// u_int32_t srclen) - x3 (used once to define srcend)
|
||||
// {
|
||||
// u_int8_t text_buf[N + F - 1];
|
||||
// u_int8_t * dststart = dst;
|
||||
// const u_int8_t * srcend = src + srclen;
|
||||
// int i, j, k, r, c;
|
||||
// unsigned int flags;
|
||||
|
||||
#define dststart x12
|
||||
#define dst x0
|
||||
#define flags w1
|
||||
#define src x2
|
||||
#define srcend x3
|
||||
#define r w4
|
||||
#define c w5
|
||||
#define i w6
|
||||
#define j w7
|
||||
#define t w8
|
||||
#define k w10
|
||||
#define text_buf sp
|
||||
#define Nm1 w11
|
||||
#define spsave x9
|
||||
|
||||
// dst = dststart;
|
||||
|
||||
mov spsave, sp // store sp as we need to align sp
|
||||
mov dststart, dst
|
||||
|
||||
// for (i = 0; i < N - F; i++) text_buf[i] = ' ';
|
||||
|
||||
lsr x1, spsave, #4 // 16-byte alignment
|
||||
|
||||
mov w5, #((32<<8)+32) // r5 = ' ';
|
||||
lsl x1, x1, #4 // 16-byte alignment
|
||||
sub sp, x1, #N // it appears that text_buf[N] is sufficient, the extra F-1 bytes is never used
|
||||
add w5, w5, w5, lsl #16 // r5 = ' ';
|
||||
mov x4, sp // r1 -> text_buf[0]
|
||||
|
||||
mov x1, #(N-F+2) // do extra 2, so that 4080 is a multiple of 16 (255)
|
||||
|
||||
dup.4s v0, w5
|
||||
|
||||
0:
|
||||
st1.4s {v0}, [x4]
|
||||
add x4, x4, #16
|
||||
subs x1, x1, #16
|
||||
b.gt 0b
|
||||
|
||||
// r = N - F;
|
||||
// flags = 0;
|
||||
|
||||
|
||||
mov w4, #N
|
||||
sub w11, w4, #1 // r11 = N-1, will be used for circular buffering in text_buf[r]
|
||||
sub w4, w4, #F // r = N-r
|
||||
mov w1, #0 // flag = 0
|
||||
|
||||
add srcend, src, x3
|
||||
|
||||
L_for_loop:
|
||||
|
||||
// for ( ; ; ) {
|
||||
|
||||
// if (((flags >>= 1) & 0x100) == 0) {
|
||||
// if (src < srcend) c = *src++; else break;
|
||||
// flags = c | 0xFF00;
|
||||
// }
|
||||
|
||||
lsr flags, flags, #1 // flags >>= 1
|
||||
tst flags, #0x100 // (flags >>= 1) & 0x100)
|
||||
b.ne L_skip1 // if != 0, skip the following
|
||||
cmp src, srcend // src vs srcend
|
||||
b.ge L_break_for_loop // if (src>=srcend) break_for_loop
|
||||
ldrb c,[src],#1 // c = *src++
|
||||
orr flags,c,#0x00ff00 // flags = c | 0xFF00;
|
||||
|
||||
L_skip1:
|
||||
|
||||
// if (flags & 1) {
|
||||
tst flags, #1
|
||||
b.eq L_skip2
|
||||
// if (src < srcend) c = *src++; else break;
|
||||
// *dst++ = c;
|
||||
// text_buf[r++] = c;
|
||||
// r &= (N - 1);
|
||||
|
||||
cmp src, srcend // src vs srcend
|
||||
b.ge L_break_for_loop // if (src>=srcend) break_for_loop
|
||||
ldrb c,[src],#1 // c = *src++
|
||||
strb c,[text_buf,r, uxtw] // text_buf[r]
|
||||
add r, r, #1 // r++
|
||||
strb c,[dst],#1 // *dst++ = c;
|
||||
and r, r, Nm1 // r &= (N - 1);
|
||||
b L_for_loop
|
||||
|
||||
// } else {
|
||||
L_skip2:
|
||||
// if (src < srcend) i = *src++; else break;
|
||||
// if (src < srcend) j = *src++; else break;
|
||||
|
||||
ldrh i,[src],#2 //
|
||||
cmp src, srcend //
|
||||
lsr j, i, #8
|
||||
b.gt L_break_for_loop
|
||||
sub i, i, j, lsl #8
|
||||
|
||||
// i |= ((j & 0xF0) << 4);
|
||||
// j = (j & 0x0F) + THRESHOLD;
|
||||
|
||||
and t, j, #0xf0 // j&0xf0
|
||||
and j, j, #0x0f // j&0x0f
|
||||
orr i, i, t, lsl #4 // i |= ((j & 0xF0) << 4);
|
||||
add j, j, #THRESHOLD // j = (j & 0x0F) + THRESHOLD;
|
||||
|
||||
// for (k = 0; k <= j; k++) {
|
||||
// c = text_buf[(i + k) & (N - 1)];
|
||||
// *dst++ = c;
|
||||
// text_buf[r++] = c;
|
||||
// r &= (N - 1);
|
||||
// }
|
||||
mov k, #0
|
||||
|
||||
0:
|
||||
add t, i, k // (i+k)
|
||||
and t, t, Nm1 // (i + k) & (N - 1)
|
||||
ldrb c, [text_buf, t, uxtw] // c = text_buf[(i + k) & (N - 1)];
|
||||
strb c, [dst], #1 // *dst++ = c;
|
||||
strb c, [text_buf, r, uxtw] // text_buf[r] = c;
|
||||
add r, r, #1 // r++
|
||||
and r, r, Nm1 // r &= (N - 1);
|
||||
add k, k, #1 // k++
|
||||
cmp k, j // k vs j
|
||||
b.le 0b
|
||||
b L_for_loop
|
||||
|
||||
// }
|
||||
// }
|
||||
|
||||
L_break_for_loop:
|
||||
sub x0, dst, dststart
|
||||
|
||||
mov sp, spsave // stores sp before 16-byte alignment
|
||||
|
||||
ret lr
|
||||
|
||||
|
||||
|
||||
// return dst - dststart;
|
||||
// }
|
||||
|
||||
#endif // __arm64__
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
# Copyright (C) 2014 Apple Inc. All rights reserved.
|
||||
#
|
||||
# This document is the property of Apple Inc.
|
||||
# It is considered confidential and proprietary.
|
||||
#
|
||||
# This document may not be reproduced or transmitted in any form,
|
||||
# in whole or in part, without the express written permission of
|
||||
# Apple Inc.
|
||||
#
|
||||
|
||||
LIBLZSS_DIR := $(GET_LOCAL_DIR)
|
||||
LIBLZSS_BUILD := $(call TOLIBDIR,$(LIBLZSS_DIR)/LIBLZSS.a)
|
||||
COMMONLIBS += LIBLZSS
|
||||
|
||||
# Only process the remainder of the makefile if we are building libraries
|
||||
#
|
||||
ifeq ($(MAKEPHASE),libraries)
|
||||
|
||||
LIBLZSS_OBJS := \
|
||||
$(LIBLZSS_DIR)/lzss.o \
|
||||
$(LIBLZSS_DIR)/$(ARCH)/lzssdec.o
|
||||
|
||||
LIBLZSS_OBJS := $(call TOLIBOBJDIR,$(LIBLZSS_OBJS))
|
||||
|
||||
ALL_DEPS += $(LIBLZSS_OBJS:%o=%d)
|
||||
|
||||
$(LIBLZSS_BUILD): $(LIBLZSS_OBJS)
|
||||
|
||||
endif
|
||||
+124
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* Copyright (c) 2007-2013 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_START@
|
||||
*
|
||||
* The contents of this file constitute Original Code as defined in and
|
||||
* are subject to the Apple Public Source License Version 1.1 (the
|
||||
* "License"). You may not use this file except in compliance with the
|
||||
* License. Please obtain a copy of the License at
|
||||
* http://www.apple.com/publicsource and read it before using this file.
|
||||
*
|
||||
* This Original Code and all software distributed under the License are
|
||||
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
#include <sys.h>
|
||||
#include <arch.h>
|
||||
#include <lib/lzss.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
uint32_t decompress_lzss_vec(uint8_t *dst, uint32_t dstlen, const uint8_t *src, uint32_t srclen);
|
||||
|
||||
#define N 4096 /* size of ring buffer - must be power of 2 */
|
||||
#define F 18 /* upper limit for match_length */
|
||||
#define THRESHOLD 2 /* encode string into position and length
|
||||
if match_length is greater than this */
|
||||
#define NIL N /* index for root of binary search trees */
|
||||
#define TEXT_BUF (N + F - 1) /* size of ring buffer with F-1 extra bytes
|
||||
to aid string comparison */
|
||||
|
||||
uint32_t decompress_lzss(uint8_t * __restrict dst, uint32_t dstlen, const uint8_t * __restrict src, uint32_t srclen)
|
||||
{
|
||||
#if (ARCH_ARMv7 && WITH_VFP) || defined(__arm64__)
|
||||
#if WITH_VFP_ALWAYS_ON
|
||||
return decompress_lzss_vec(dst, dstlen, src, srclen);
|
||||
#else
|
||||
bool fp_enabled;
|
||||
uint32_t result;
|
||||
|
||||
fp_enabled = arch_task_fp_enable(true);
|
||||
result = decompress_lzss_vec(dst, dstlen, src, srclen);
|
||||
arch_task_fp_enable(fp_enabled);
|
||||
return result;
|
||||
#endif // WITH_VFP_ALWAYS_ON
|
||||
#else
|
||||
uint8_t *text_buf = NULL;
|
||||
uint8_t *dststart = dst;
|
||||
uint8_t *dstend = dst + dstlen;
|
||||
const uint8_t *srcend = src + srclen;
|
||||
uint32_t i, j, k, r, c;
|
||||
uint32_t flags;
|
||||
uint32_t result = 0;
|
||||
|
||||
text_buf = (uint8_t *)malloc(TEXT_BUF);
|
||||
if (text_buf == NULL)
|
||||
goto error;
|
||||
memset(text_buf, ' ', N - F);
|
||||
|
||||
r = N - F;
|
||||
flags = 0;
|
||||
for ( ; ; ) {
|
||||
if (((flags >>= 1) & 0x100) == 0) {
|
||||
if (src < srcend) {
|
||||
c = *src++;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
flags = c | 0xFF00; /* uses higher byte cleverly */
|
||||
} /* to count eight */
|
||||
if (flags & 1) {
|
||||
if (src < srcend) {
|
||||
c = *src++;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
if (dst == dstend) {
|
||||
goto error;
|
||||
}
|
||||
*dst++ = c;
|
||||
text_buf[r++] = c;
|
||||
r &= (N - 1);
|
||||
} else {
|
||||
if (src < srcend) {
|
||||
i = *src++;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
if (src < srcend) {
|
||||
j = *src++;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
i |= ((j & 0xF0) << 4);
|
||||
j = (j & 0x0F) + THRESHOLD;
|
||||
for (k = 0; k <= j; k++) {
|
||||
c = text_buf[(i + k) & (N - 1)];
|
||||
if (dst == dstend) {
|
||||
goto error;
|
||||
}
|
||||
*dst++ = c;
|
||||
text_buf[r++] = c;
|
||||
r &= (N - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result = dst - dststart;
|
||||
|
||||
error:
|
||||
if (text_buf != NULL)
|
||||
free(text_buf);
|
||||
|
||||
return result;
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
# Copyright (C) 2007, 2012-2014 Apple Inc. All rights reserved.
|
||||
# Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
|
||||
#
|
||||
# This document is the property of Apple Computer, Inc.
|
||||
# It is considered confidential and proprietary.
|
||||
#
|
||||
# This document may not be reproduced or transmitted in any form,
|
||||
# in whole or in part, without the express written permission of
|
||||
# Apple Inc.
|
||||
#
|
||||
|
||||
OPTIONS += WITH_LZSS=1
|
||||
LIBRARY_MODULES += lib/lzss
|
||||
@@ -0,0 +1,76 @@
|
||||
#include <unittest.h>
|
||||
#include <lib/lzss.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
struct lzss_test {
|
||||
const uint8_t *input;
|
||||
size_t input_len;
|
||||
const uint8_t *expected;
|
||||
size_t expected_len;
|
||||
size_t buf_len;
|
||||
};
|
||||
|
||||
struct lzss_test tests[] = {
|
||||
{
|
||||
(const uint8_t *)&(const uint8_t[]){ 0xff, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87 },
|
||||
9,
|
||||
(const uint8_t *)&(const uint8_t[]){ 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87 },
|
||||
8,
|
||||
4096
|
||||
},
|
||||
#if 0
|
||||
{
|
||||
(const uint8_t *)&(const uint8_t[]){ 0xff, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x00, 0x00, 0x00 },
|
||||
12,
|
||||
(const uint8_t *)&(const uint8_t[]){ 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x80, 0x81, 0x82 },
|
||||
11,
|
||||
4096
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
void test_lzss(uintptr_t param)
|
||||
{
|
||||
struct lzss_test *test = (struct lzss_test *)param;
|
||||
uint32_t guard = 0xdeadbeef;
|
||||
uint8_t *dst;
|
||||
uint32_t result;
|
||||
|
||||
dst = malloc(test->buf_len + sizeof(guard));
|
||||
memset(dst, 0xcc, test->buf_len);
|
||||
|
||||
// If the test is expected to succeed, put a guard right
|
||||
// after the last expected output byte of the buffer; if it's
|
||||
// expected to fail, just put it at the end of the buffer
|
||||
if (test->expected_len != 0)
|
||||
memcpy(dst + test->expected_len, &guard, sizeof(guard));
|
||||
else
|
||||
memcpy(dst + test->buf_len, &guard, sizeof(guard));
|
||||
|
||||
result = decompress_lzss(dst, test->buf_len, test->input, test->input_len);
|
||||
TEST_ASSERT_EQ(result, test->expected_len);
|
||||
|
||||
if (test->expected_len != 0) {
|
||||
TEST_ASSERT_MEM_EQ(dst, test->expected, test->expected_len);
|
||||
TEST_ASSERT_MEM_EQ(dst + test->expected_len, &guard, sizeof(guard));
|
||||
} else {
|
||||
TEST_ASSERT_MEM_EQ(dst + test->buf_len, &guard, sizeof(guard));
|
||||
}
|
||||
|
||||
free(dst);
|
||||
}
|
||||
|
||||
static struct test_suite lzss_test_suite = {
|
||||
.name = "lzss",
|
||||
.description = "tests the lzss implementation",
|
||||
.test_cases = {
|
||||
{ "lzss", test_lzss, (uintptr_t)&tests[0] },
|
||||
#if 0
|
||||
{ "lzss", test_lzss, (uintptr_t)&tests[1] },
|
||||
#endif
|
||||
TEST_CASE_LAST
|
||||
}
|
||||
};
|
||||
|
||||
TEST_SUITE(lzss_test_suite);
|
||||
@@ -0,0 +1,20 @@
|
||||
# Copyright (C) 2014 Apple Inc. All rights reserved.
|
||||
#
|
||||
# This document is the property of Apple Inc.
|
||||
# It is considered confidential and proprietary.
|
||||
#
|
||||
# This document may not be reproduced or transmitted in any form,
|
||||
# in whole or in part, without the express written permission of
|
||||
# Apple Inc.
|
||||
#
|
||||
|
||||
LOCAL_DIR := $(GET_LOCAL_DIR)
|
||||
|
||||
TEST_NAME := lzss
|
||||
|
||||
TEST_OBJS := \
|
||||
$(LOCAL_DIR)/lzss.o
|
||||
|
||||
TEST_SUPPORT_OBJS := \
|
||||
tests/unittest-main.o \
|
||||
$(LOCAL_DIR)/tests.o
|
||||
Reference in new issue
Block a user