1*0d6140beSAndroid Build Coastguard Worker /* 2*0d6140beSAndroid Build Coastguard Worker * This file is part of the flashrom project. 3*0d6140beSAndroid Build Coastguard Worker * 4*0d6140beSAndroid Build Coastguard Worker * Copyright (C) 2021, Google Inc. All rights reserved. 5*0d6140beSAndroid Build Coastguard Worker * 6*0d6140beSAndroid Build Coastguard Worker * This program is free software; you can redistribute it and/or modify 7*0d6140beSAndroid Build Coastguard Worker * it under the terms of the GNU General Public License as published by 8*0d6140beSAndroid Build Coastguard Worker * the Free Software Foundation; either version 2 of the License, or 9*0d6140beSAndroid Build Coastguard Worker * (at your option) any later version. 10*0d6140beSAndroid Build Coastguard Worker * 11*0d6140beSAndroid Build Coastguard Worker * This program is distributed in the hope that it will be useful, 12*0d6140beSAndroid Build Coastguard Worker * but WITHOUT ANY WARRANTY; without even the implied warranty of 13*0d6140beSAndroid Build Coastguard Worker * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14*0d6140beSAndroid Build Coastguard Worker * GNU General Public License for more details. 15*0d6140beSAndroid Build Coastguard Worker */ 16*0d6140beSAndroid Build Coastguard Worker 17*0d6140beSAndroid Build Coastguard Worker #include "io_mock.h" 18*0d6140beSAndroid Build Coastguard Worker 19*0d6140beSAndroid Build Coastguard Worker static const struct io_mock *current_io = NULL; 20*0d6140beSAndroid Build Coastguard Worker io_mock_register(const struct io_mock * io)21*0d6140beSAndroid Build Coastguard Workervoid io_mock_register(const struct io_mock *io) 22*0d6140beSAndroid Build Coastguard Worker { 23*0d6140beSAndroid Build Coastguard Worker /* A test can either register its own mock open function or fallback_open_state. */ 24*0d6140beSAndroid Build Coastguard Worker assert_true(io == NULL || io->iom_open == NULL || io->fallback_open_state == NULL); 25*0d6140beSAndroid Build Coastguard Worker current_io = io; 26*0d6140beSAndroid Build Coastguard Worker } 27*0d6140beSAndroid Build Coastguard Worker get_io(void)28*0d6140beSAndroid Build Coastguard Workerconst struct io_mock *get_io(void) 29*0d6140beSAndroid Build Coastguard Worker { 30*0d6140beSAndroid Build Coastguard Worker return current_io; 31*0d6140beSAndroid Build Coastguard Worker } 32