1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-04-26 22:52:34 +02:00
flashrom/tests/flashrom.c
Anastasia Klimchuk 84bfe0e04e tests: Add header stdlib.h to allow scan-build to do analysis
Without the header being explicitly included, scan-build run on CI
was returning errors for these files, such as:

include the header <stdlib.h> or explicitly provide a declaration
for 'calloc'

The functions in question were calloc, free, etc.

Change-Id: I4b79c5f86c074c456533296c309293e4064abe3f
Signed-off-by: Anastasia Klimchuk <aklm@flashrom.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/84455
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2024-09-25 01:46:27 +00:00

73 lines
1.8 KiB
C

/*
* This file is part of the flashrom project.
*
* Copyright 2020 Google LLC
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include <stdlib.h>
#include <include/test.h>
#include "tests.h"
#include "programmer.h"
#define assert_equal_and_free(text, expected) \
do { \
assert_string_equal(text, expected); \
free(text); \
} while (0)
#define assert_not_equal_and_free(text, expected) \
do { \
assert_string_not_equal(text, expected); \
free(text); \
} while (0)
void flashbuses_to_text_test_success(void **state)
{
(void) state; /* unused */
enum chipbustype bustype;
char *text;
bustype = BUS_NONSPI;
text = flashbuses_to_text(bustype);
assert_equal_and_free(text, "Non-SPI");
bustype |= BUS_PARALLEL;
text = flashbuses_to_text(bustype);
assert_not_equal_and_free(text, "Non-SPI, Parallel");
bustype = BUS_PARALLEL;
bustype |= BUS_LPC;
text = flashbuses_to_text(bustype);
assert_equal_and_free(text, "Parallel, LPC");
bustype |= BUS_FWH;
//BUS_NONSPI = BUS_PARALLEL | BUS_LPC | BUS_FWH,
text = flashbuses_to_text(bustype);
assert_equal_and_free(text, "Non-SPI");
bustype |= BUS_SPI;
text = flashbuses_to_text(bustype);
assert_equal_and_free(text, "Parallel, LPC, FWH, SPI");
bustype |= BUS_PROG;
text = flashbuses_to_text(bustype);
assert_equal_and_free(text,
"Parallel, LPC, FWH, SPI, Programmer-specific");
bustype = BUS_NONE;
text = flashbuses_to_text(bustype);
assert_equal_and_free(text, "None");
}