mirror of
				https://review.coreboot.org/flashrom.git
				synced 2025-11-03 23:00:13 +01:00 
			
		
		
		
	Change-Id: I3a8a8e59cbed871e0ecf953e547de56c0656e112 Signed-off-by: Anastasia Klimchuk <aklm@flashrom.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/89361 Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org> Reviewed-by: Peter Marheine <pmarheine@chromium.org> Reviewed-by: Antonio Vázquez Blanco <antoniovazquezblanco@gmail.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
		
			
				
	
	
		
			65 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			65 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
/*
 | 
						|
 * This file is part of the flashrom project.
 | 
						|
 *
 | 
						|
 * SPDX-License-Identifier: GPL-2.0-only
 | 
						|
 * SPDX-FileCopyrightText: 2020 Google LLC
 | 
						|
 */
 | 
						|
 | 
						|
#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");
 | 
						|
}
 |