static struct value *global_SCOPEcalein_write_SPACEline_ARG(struct value *s) { value_write(s); puts(""); fflush(stdout); value_remove_reference(s); return 0; };
/** * ib_unpack - Unpack a buffer into a structure * @desc:Array of structure field descriptions * @desc_len:Number of entries in @desc * @buf:Buffer to unpack from * @structure:Structure to unpack into * * ib_pack() unpacks a list of structure fields from a buffer, * controlled by the array of fields in @desc. */ void ib_unpack(const struct ib_field *desc, int desc_len, void *buf, void *structure) { int i; for (i = 0; i < desc_len; ++i) { if (!desc[i].struct_size_bytes) continue; if (desc[i].size_bits <= 32) { int shift; u32 val; u32 mask; __be32 *addr; shift = 32 - desc[i].offset_bits - desc[i].size_bits; mask = ((1ull << desc[i].size_bits) - 1) << shift; addr = (__be32 *) buf + desc[i].offset_words; val = (be32_to_cpup(addr) & mask) >> shift; value_write(desc[i].struct_offset_bytes, desc[i].struct_size_bytes, val, structure); } else if (desc[i].size_bits <= 64) {
int datapoint_write(datapoint_t* p, int fd) { if ((timestamp_write(p->t, fd) != 0) || (value_write(p->v, fd) != 0)) return -1; return 0; }
void replication_service_test_app::write_backup_metadata_test() { cold_backup_context_ptr backup_context = new cold_backup_context(nullptr, request, concurrent_uploading_file_cnt); backup_context->start_check(); backup_context->block_service = block_service.get(); backup_context->backup_root = backup_root; backup_context->_status.store(cold_backup_status::ColdBackupUploading); // case1: create backup_metadata file fail // this case has been already tested // case2: create backup_metadata file succeed, but write file fail // this case has been already tested // case3: create backup_metadata file succeed, and write file succeed { std::cout << "create backup_metadata_file succeed, and write file succeed..." << std::endl; std::string test_file1 = "test_file1"; std::string test_file2 = "test_file2"; backup_context->_metadata.checkpoint_decree = 100; file_meta f_meta; f_meta.name = test_file1; f_meta.md5 = "test_file1_md5"; f_meta.size = 10; backup_context->_metadata.files.emplace_back(f_meta); f_meta.name = test_file2; f_meta.md5 = "test_file2_md5"; f_meta.size = 11; backup_context->_metadata.files.emplace_back(f_meta); blob result = ::json::json_forwarder<cold_backup_metadata>::encode(backup_context->_metadata); std::string value(result.data(), result.length()); current_chkpt_file->enable_write_fail = true; backup_context->write_backup_metadata(); std::string value_write(backup_metadata_file->context.data(), backup_metadata_file->context.length()); ASSERT_TRUE(result.data() != backup_metadata_file->context.data()); ASSERT_TRUE(value == value_write); ASSERT_TRUE(backup_context->status() == cold_backup_status::ColdBackupFailed); current_chkpt_file->enable_write_fail = false; backup_context->_metadata.files.clear(); } ASSERT_TRUE(backup_context->get_count() == 1); ASSERT_TRUE(current_chkpt_file->get_count() == 1); ASSERT_TRUE(backup_metadata_file->get_count() == 1); ASSERT_TRUE(regular_file->get_count() == 1); }
static struct value *global_SCOPEcalein_write_ARG(struct value *s) { value_write(s); value_remove_reference(s); return 0; };