blob: 99b36425f5deec1b5d347762aea60e3a8ebf7987 [file] [log] [blame]
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
#include "fcb_test.h"
TEST_CASE(fcb_test_append_too_big)
{
struct fcb *fcb;
int rc;
int len;
struct fcb_entry elem_loc;
#if 0
fcb_test_wipe();
fcb = &test_fcb;
memset(fcb, 0, sizeof(*fcb));
fcb->f_sector_cnt = 2;
fcb->f_sectors = test_fcb_area;
rc = fcb_init(fcb);
TEST_ASSERT(rc == 0);
#endif
fcb = &test_fcb;
/*
* Max element which fits inside sector is
* sector size - (disk header + crc + 1-2 bytes of length).
*/
len = fcb->f_active.fe_area->fa_size;
rc = fcb_append(fcb, len, &elem_loc);
TEST_ASSERT(rc != 0);
len--;
rc = fcb_append(fcb, len, &elem_loc);
TEST_ASSERT(rc != 0);
len -= sizeof(struct fcb_disk_area);
rc = fcb_append(fcb, len, &elem_loc);
TEST_ASSERT(rc != 0);
len = fcb->f_active.fe_area->fa_size -
(sizeof(struct fcb_disk_area) + 1 + 2);
rc = fcb_append(fcb, len, &elem_loc);
TEST_ASSERT(rc == 0);
rc = fcb_append_finish(fcb, &elem_loc);
TEST_ASSERT(rc == 0);
rc = fcb_elem_info(fcb, &elem_loc);
TEST_ASSERT(rc == 0);
TEST_ASSERT(elem_loc.fe_data_len == len);
}