Commit 949e9eb1 authored by 4ast's avatar 4ast

Merge pull request #119 from iovisor/bblanco_dev

Patch series: reorganize bpf_module and add sscanf feature for fuse
parents fdb3f74e 5c387ba4
......@@ -33,7 +33,8 @@ add_library(bpfprog SHARED bpf_common.cc bpf_module.cc libbpf.c)
# BPF is still experimental otherwise it should be available
#llvm_map_components_to_libnames(llvm_libs bpf mcjit irreader passes)
llvm_map_components_to_libnames(llvm_libs mcjit irreader passes linker instrumentation objcarcopts bitwriter option)
llvm_map_components_to_libnames(llvm_libs mcjit irreader passes linker
instrumentation objcarcopts bitwriter option x86codegen)
# order is important
set(clang_libs ${libclangFrontend} ${libclangSerialization} ${libclangDriver} ${libclangParse}
${libclangSema} ${libclangCodeGen} ${libclangAnalysis} ${libclangRewrite} ${libclangEdit}
......
......@@ -146,4 +146,40 @@ const char * bpf_table_leaf_desc_id(void *program, size_t id) {
return mod->table_leaf_desc(id);
}
size_t bpf_table_key_size(void *program, const char *table_name) {
auto mod = static_cast<ebpf::BPFModule *>(program);
if (!mod) return 0;
return mod->table_key_size(table_name);
}
size_t bpf_table_key_size_id(void *program, size_t id) {
auto mod = static_cast<ebpf::BPFModule *>(program);
if (!mod) return 0;
return mod->table_key_size(id);
}
size_t bpf_table_leaf_size(void *program, const char *table_name) {
auto mod = static_cast<ebpf::BPFModule *>(program);
if (!mod) return 0;
return mod->table_leaf_size(table_name);
}
size_t bpf_table_leaf_size_id(void *program, size_t id) {
auto mod = static_cast<ebpf::BPFModule *>(program);
if (!mod) return 0;
return mod->table_leaf_size(id);
}
int bpf_table_update(void *program, const char *table_name, const char *key, const char *leaf) {
auto mod = static_cast<ebpf::BPFModule *>(program);
if (!mod) return 0;
return mod->table_update(table_name, key, leaf);
}
int bpf_table_update_id(void *program, size_t id, const char *key, const char *leaf) {
auto mod = static_cast<ebpf::BPFModule *>(program);
if (!mod) return 0;
return mod->table_update(id, key, leaf);
}
}
......@@ -44,6 +44,12 @@ const char * bpf_table_key_desc(void *program, const char *table_name);
const char * bpf_table_key_desc_id(void *program, size_t id);
const char * bpf_table_leaf_desc(void *program, const char *table_name);
const char * bpf_table_leaf_desc_id(void *program, size_t id);
size_t bpf_table_key_size(void *program, const char *table_name);
size_t bpf_table_key_size_id(void *program, size_t id);
size_t bpf_table_leaf_size(void *program, const char *table_name);
size_t bpf_table_leaf_size_id(void *program, size_t id);
int bpf_table_update(void *program, const char *table_name, const char *key, const char *leaf);
int bpf_table_update_id(void *program, size_t id, const char *key, const char *leaf);
#ifdef __cplusplus
}
......
This diff is collapsed.
......@@ -24,12 +24,14 @@
namespace llvm {
class ExecutionEngine;
class Function;
class LLVMContext;
class Module;
class Type;
}
namespace ebpf {
class BPFTable;
class TableDesc;
class BLoader;
class ClangLoader;
......@@ -39,11 +41,15 @@ class BPFModule {
int init_engine();
int parse(llvm::Module *mod);
int finalize();
void dump_ir();
int annotate();
std::unique_ptr<llvm::ExecutionEngine> finalize_reader(std::unique_ptr<llvm::Module> mod);
llvm::Function * make_reader(llvm::Module *mod, llvm::Type *type);
void dump_ir(llvm::Module &mod);
int load_file_module(std::unique_ptr<llvm::Module> *mod, const std::string &file, bool in_memory);
int load_includes(const std::string &tmpfile);
int load_cfile(const std::string &file, bool in_memory);
int kbuild_flags(const char *uname_release, std::vector<std::string> *cflags);
int run_pass_manager(llvm::Module &mod);
public:
BPFModule(unsigned flags);
~BPFModule();
......@@ -62,8 +68,14 @@ class BPFModule {
const char * table_name(size_t id) const;
const char * table_key_desc(size_t id) const;
const char * table_key_desc(const std::string &name) const;
size_t table_key_size(size_t id) const;
size_t table_key_size(const std::string &name) const;
const char * table_leaf_desc(size_t id) const;
const char * table_leaf_desc(const std::string &name) const;
size_t table_leaf_size(size_t id) const;
size_t table_leaf_size(const std::string &name) const;
int table_update(size_t id, const char *key, const char *leaf);
int table_update(const std::string &name, const char *key, const char *leaf);
char * license() const;
unsigned kern_version() const;
private:
......@@ -72,13 +84,15 @@ class BPFModule {
std::string proto_filename_;
std::unique_ptr<llvm::LLVMContext> ctx_;
std::unique_ptr<llvm::ExecutionEngine> engine_;
llvm::Module *mod_;
std::unique_ptr<llvm::ExecutionEngine> reader_engine_;
std::unique_ptr<llvm::Module> mod_;
std::unique_ptr<BLoader> b_loader_;
std::unique_ptr<ClangLoader> clang_loader_;
std::map<std::string, std::tuple<uint8_t *, uintptr_t>> sections_;
std::unique_ptr<std::map<std::string, BPFTable>> tables_;
std::vector<std::string> table_names_;
std::unique_ptr<std::vector<TableDesc>> tables_;
std::map<std::string, size_t> table_names_;
std::vector<std::string> function_names_;
std::map<llvm::Type *, llvm::Function *> readers_;
};
} // namespace ebpf
......@@ -36,6 +36,7 @@
#include "exception.h"
#include "codegen_llvm.h"
#include "lexer.h"
#include "table_desc.h"
#include "type_helper.h"
#include "linux/bpf.h"
#include "libbpf.h"
......@@ -47,6 +48,7 @@ using namespace llvm;
using std::for_each;
using std::make_tuple;
using std::map;
using std::pair;
using std::set;
using std::string;
......@@ -1085,20 +1087,17 @@ StatusTuple CodegenLLVM::visit_table_decl_stmt_node(TableDeclStmtNode *n) {
else
return mkstatus_(n, "Table type %s not implemented", n->type_id()->name_.c_str());
StructType *key_stype, *leaf_stype;
TRY2(lookup_struct_type(n->key_type_, &key_stype));
TRY2(lookup_struct_type(n->leaf_type_, &leaf_stype));
StructType *decl_struct = mod_->getTypeByName("_struct." + n->id_->name_);
if (!decl_struct)
decl_struct = StructType::create(ctx(), "_struct." + n->id_->name_);
if (decl_struct->isOpaque())
decl_struct->setBody(std::vector<Type *>({Type::getInt32Ty(ctx()), Type::getInt32Ty(ctx()),
Type::getInt32Ty(ctx()), Type::getInt32Ty(ctx())}),
/*isPacked=*/false);
decl_struct->setBody(vector<Type *>({key_stype, leaf_stype}), /*isPacked=*/false);
GlobalVariable *decl_gvar = new GlobalVariable(*mod_, decl_struct, false,
GlobalValue::ExternalLinkage, 0, n->id_->name_);
decl_gvar->setSection("maps");
vector<Constant *> struct_init = { B.getInt32(map_type), B.getInt32(key->bit_width_ / 8),
B.getInt32(leaf->bit_width_ / 8), B.getInt32(n->size_)};
Constant *const_struct = ConstantStruct::get(decl_struct, struct_init);
decl_gvar->setInitializer(const_struct);
tables_[n] = decl_gvar;
int map_fd = bpf_create_map(map_type, key->bit_width_ / 8, leaf->bit_width_ / 8, n->size_);
......@@ -1168,7 +1167,7 @@ StatusTuple CodegenLLVM::visit_func_decl_stmt_node(FuncDeclStmtNode *n) {
BasicBlock *label_entry = BasicBlock::Create(ctx(), "entry", fn);
B.SetInsertPoint(label_entry);
string scoped_entry_label = std::to_string((uintptr_t)fn) + "::entry";
string scoped_entry_label = to_string((uintptr_t)fn) + "::entry";
labels_[scoped_entry_label] = label_entry;
BasicBlock *label_return = resolve_label("DONE");
retval_ = new AllocaInst(fn->getReturnType(), "ret", label_entry);
......@@ -1219,7 +1218,7 @@ StatusTuple CodegenLLVM::visit_func_decl_stmt_node(FuncDeclStmtNode *n) {
return mkstatus(0);
}
StatusTuple CodegenLLVM::visit(Node* root) {
StatusTuple CodegenLLVM::visit(Node* root, vector<TableDesc> &tables) {
scopes_->set_current(scopes_->top_state());
scopes_->set_current(scopes_->top_var());
......@@ -1232,6 +1231,16 @@ StatusTuple CodegenLLVM::visit(Node* root) {
TRY2((*it)->accept(this));
//TRY2(print_parser());
for (auto table : tables_) {
tables.push_back({
table.first->id_->name_,
table_fds_[table.first],
table.first->key_type_->bit_width_ >> 3,
table.first->leaf_type_->bit_width_ >> 3,
table.first->size_,
"", "",
});
}
return mkstatus(0);
}
......@@ -1263,7 +1272,7 @@ StatusTuple CodegenLLVM::print_header() {
return mkstatus(0);
}
int CodegenLLVM::get_table_fd(const std::string &name) const {
int CodegenLLVM::get_table_fd(const string &name) const {
TableDeclStmtNode *table = scopes_->top_table()->lookup(name);
if (!table)
return -1;
......@@ -1291,7 +1300,7 @@ Value * CodegenLLVM::pop_expr() {
BasicBlock * CodegenLLVM::resolve_label(const string &label) {
Function *parent = B.GetInsertBlock()->getParent();
string scoped_label = std::to_string((uintptr_t)parent) + "::" + label;
string scoped_label = to_string((uintptr_t)parent) + "::" + label;
auto it = labels_.find(scoped_label);
if (it != labels_.end()) return it->second;
BasicBlock *label_new = BasicBlock::Create(ctx(), label, parent);
......
......@@ -16,6 +16,7 @@
#pragma once
#include <map>
#include <stdio.h>
#include <vector>
#include <string>
......@@ -40,6 +41,8 @@ class GlobalVariable;
}
namespace ebpf {
class TableDesc;
namespace cc {
class BlockStack;
......@@ -60,7 +63,7 @@ class CodegenLLVM : public Visitor {
EXPAND_NODES(VISIT)
#undef VISIT
virtual STATUS_RETURN visit(Node* n);
virtual STATUS_RETURN visit(Node* n, std::vector<TableDesc> &tables);
int get_table_fd(const std::string &name) const;
......
......@@ -18,9 +18,12 @@
#include "type_check.h"
#include "codegen_llvm.h"
#include "loader.h"
#include "table_desc.h"
using std::get;
using std::string;
using std::unique_ptr;
using std::vector;
namespace ebpf {
......@@ -30,7 +33,8 @@ BLoader::BLoader() {
BLoader::~BLoader() {
}
int BLoader::parse(llvm::Module *mod, const string &filename, const string &proto_filename) {
int BLoader::parse(llvm::Module *mod, const string &filename, const string &proto_filename,
unique_ptr<vector<TableDesc>> *tables) {
int rc;
proto_parser_ = make_unique<ebpf::cc::Parser>(proto_filename);
......@@ -57,8 +61,10 @@ int BLoader::parse(llvm::Module *mod, const string &filename, const string &prot
return -1;
}
*tables = make_unique<vector<TableDesc>>();
codegen_ = ebpf::make_unique<ebpf::cc::CodegenLLVM>(mod, parser_->scopes_.get(), proto_parser_->scopes_.get());
ret = codegen_->visit(parser_->root_node_);
ret = codegen_->visit(parser_->root_node_, **tables);
if (get<0>(ret) != 0 || get<1>(ret).size()) {
fprintf(stderr, "Codegen error @line=%d: %s\n", get<0>(ret), get<1>(ret).c_str());
return get<0>(ret);
......@@ -67,9 +73,4 @@ int BLoader::parse(llvm::Module *mod, const string &filename, const string &prot
return 0;
}
int BLoader::get_table_fd(const string &name) const {
if (!codegen_) return -1;
return codegen_->get_table_fd(name);
}
} // namespace ebpf
......@@ -16,6 +16,8 @@
#pragma once
#include <map>
#include <memory>
#include <string>
namespace llvm {
......@@ -24,6 +26,8 @@ class Module;
namespace ebpf {
class TableDesc;
namespace cc {
class Parser;
class CodegenLLVM;
......@@ -33,8 +37,8 @@ class BLoader {
public:
BLoader();
~BLoader();
int parse(llvm::Module *mod, const std::string &filename, const std::string &proto_filename);
int get_table_fd(const std::string &name) const;
int parse(llvm::Module *mod, const std::string &filename, const std::string &proto_filename,
std::unique_ptr<std::vector<TableDesc>> *tables);
private:
std::unique_ptr<cc::Parser> parser_;
std::unique_ptr<cc::Parser> proto_parser_;
......
......@@ -51,6 +51,13 @@ bool BMapDeclVisitor::VisitFieldDecl(FieldDecl *D) {
result_ += "\",";
return true;
}
bool BMapDeclVisitor::TraverseRecordDecl(RecordDecl *D) {
// skip children, handled in Visit...
if (!WalkUpFromRecordDecl(D))
return false;
return true;
}
bool BMapDeclVisitor::VisitRecordDecl(RecordDecl *D) {
result_ += "[\"";
result_ += D->getName();
......@@ -65,7 +72,7 @@ bool BMapDeclVisitor::VisitRecordDecl(RecordDecl *D) {
if (!D->getDefinition()->field_empty())
result_.erase(result_.end() - 2);
result_ += "]]";
return false;
return true;
}
bool BMapDeclVisitor::VisitTagType(const TagType *T) {
return TraverseDecl(T->getDecl()->getDefinition());
......@@ -80,7 +87,7 @@ bool BMapDeclVisitor::VisitBuiltinType(const BuiltinType *T) {
return true;
}
BTypeVisitor::BTypeVisitor(ASTContext &C, Rewriter &rewriter, map<string, BPFTable> &tables)
BTypeVisitor::BTypeVisitor(ASTContext &C, Rewriter &rewriter, vector<TableDesc> &tables)
: C(C), rewriter_(rewriter), out_(llvm::errs()), tables_(tables) {
}
......@@ -135,13 +142,15 @@ bool BTypeVisitor::VisitCallExpr(CallExpr *Call) {
string args = rewriter_.getRewrittenText(argRange);
// find the table fd, which was opened at declaration time
auto table_it = tables_.find(Ref->getDecl()->getName());
auto table_it = tables_.begin();
for (; table_it != tables_.end(); ++table_it)
if (table_it->name == Ref->getDecl()->getName()) break;
if (table_it == tables_.end()) {
C.getDiagnostics().Report(Ref->getLocEnd(), diag::err_expected)
<< "initialized handle for bpf_table";
return false;
}
string fd = to_string(table_it->second.fd);
string fd = to_string(table_it->fd);
string prefix, suffix;
string map_update_policy = "BPF_ANY";
string txt;
......@@ -354,18 +363,23 @@ bool BTypeVisitor::VisitVarDecl(VarDecl *Decl) {
return false;
}
const RecordDecl *RD = R->getDecl()->getDefinition();
BPFTable table;
TableDesc table;
table.name = Decl->getName();
unsigned i = 0;
for (auto F : RD->fields()) {
size_t sz = C.getTypeSize(F->getType()) >> 3;
if (F->getName() == "key") {
table.key_size = sz;
BMapDeclVisitor visitor(C, table.key_desc);
visitor.TraverseType(F->getType());
if (!visitor.TraverseType(F->getType()))
return false;
} else if (F->getName() == "leaf") {
table.leaf_size = sz;
BMapDeclVisitor visitor(C, table.leaf_desc);
visitor.TraverseType(F->getType());
if (!visitor.TraverseType(F->getType()))
return false;
} else if (F->getName() == "data") {
table.max_entries = sz / table.leaf_size;
}
......@@ -397,7 +411,7 @@ bool BTypeVisitor::VisitVarDecl(VarDecl *Decl) {
<< "valid bpf fd";
return false;
}
tables_[Decl->getName()] = std::move(table);
tables_.push_back(std::move(table));
} else if (const PointerType *P = Decl->getType()->getAs<PointerType>()) {
// if var is a pointer to a packet type, clone the annotation into the var
// decl so that the packet dext/dins rewriter can catch it
......@@ -414,7 +428,7 @@ bool BTypeVisitor::VisitVarDecl(VarDecl *Decl) {
return true;
}
BTypeConsumer::BTypeConsumer(ASTContext &C, Rewriter &rewriter, map<string, BPFTable> &tables)
BTypeConsumer::BTypeConsumer(ASTContext &C, Rewriter &rewriter, vector<TableDesc> &tables)
: visitor_(C, rewriter, tables) {
}
......@@ -425,7 +439,7 @@ bool BTypeConsumer::HandleTopLevelDecl(DeclGroupRef D) {
}
BFrontendAction::BFrontendAction(llvm::raw_ostream &os)
: rewriter_(new Rewriter), os_(os), tables_(new map<string, BPFTable>) {
: rewriter_(new Rewriter), os_(os), tables_(new vector<TableDesc>) {
}
void BFrontendAction::EndSourceFileAction() {
......
......@@ -23,6 +23,8 @@
#include <clang/Frontend/FrontendAction.h>
#include <clang/Rewrite/Core/Rewriter.h>
#include "table_desc.h"
namespace clang {
class ASTConsumer;
class ASTContext;
......@@ -36,25 +38,16 @@ class StringRef;
namespace ebpf {
struct BPFTable {
int fd;
size_t key_size;
size_t leaf_size;
size_t max_entries;
std::string key_desc;
std::string leaf_desc;
};
// Helper visitor for constructing a string representation of a key/leaf decl
class BMapDeclVisitor : public clang::RecursiveASTVisitor<BMapDeclVisitor> {
public:
explicit BMapDeclVisitor(clang::ASTContext &C, std::string &result);
bool TraverseRecordDecl(clang::RecordDecl *Decl);
bool VisitRecordDecl(clang::RecordDecl *Decl);
bool VisitFieldDecl(clang::FieldDecl *Decl);
bool VisitBuiltinType(const clang::BuiltinType *T);
bool VisitTypedefType(const clang::TypedefType *T);
bool VisitTagType(const clang::TagType *T);
const std::string & str() const { return result_; }
private:
clang::ASTContext &C;
std::string &result_;
......@@ -67,7 +60,7 @@ class BMapDeclVisitor : public clang::RecursiveASTVisitor<BMapDeclVisitor> {
class BTypeVisitor : public clang::RecursiveASTVisitor<BTypeVisitor> {
public:
explicit BTypeVisitor(clang::ASTContext &C, clang::Rewriter &rewriter,
std::map<std::string, BPFTable> &tables);
std::vector<TableDesc> &tables);
bool TraverseCallExpr(clang::CallExpr *Call);
bool TraverseMemberExpr(clang::MemberExpr *E);
bool VisitFunctionDecl(clang::FunctionDecl *D);
......@@ -82,7 +75,7 @@ class BTypeVisitor : public clang::RecursiveASTVisitor<BTypeVisitor> {
clang::ASTContext &C;
clang::Rewriter &rewriter_; /// modifications to the source go into this class
llvm::raw_ostream &out_; /// for debugging
std::map<std::string, BPFTable> &tables_; /// store the open FDs
std::vector<TableDesc> &tables_; /// store the open FDs
std::vector<clang::ParmVarDecl *> fn_args_;
};
......@@ -90,7 +83,7 @@ class BTypeVisitor : public clang::RecursiveASTVisitor<BTypeVisitor> {
class BTypeConsumer : public clang::ASTConsumer {
public:
explicit BTypeConsumer(clang::ASTContext &C, clang::Rewriter &rewriter,
std::map<std::string, BPFTable> &tables);
std::vector<TableDesc> &tables);
bool HandleTopLevelDecl(clang::DeclGroupRef D) override;
private:
BTypeVisitor visitor_;
......@@ -113,11 +106,11 @@ class BFrontendAction : public clang::ASTFrontendAction {
CreateASTConsumer(clang::CompilerInstance &Compiler, llvm::StringRef InFile) override;
// take ownership of the table-to-fd mapping data structure
std::unique_ptr<std::map<std::string, BPFTable>> take_tables() { return move(tables_); }
std::unique_ptr<std::vector<TableDesc>> take_tables() { return move(tables_); }
private:
std::unique_ptr<clang::Rewriter> rewriter_;
llvm::raw_ostream &os_;
std::unique_ptr<std::map<std::string, BPFTable>> tables_;
std::unique_ptr<std::vector<TableDesc>> tables_;
};
} // namespace visitor
......@@ -64,8 +64,7 @@ ClangLoader::ClangLoader(llvm::LLVMContext *ctx)
ClangLoader::~ClangLoader() {}
int ClangLoader::parse(unique_ptr<llvm::Module> *mod,
unique_ptr<map<string, BPFTable>> *tables,
int ClangLoader::parse(unique_ptr<llvm::Module> *mod, unique_ptr<vector<TableDesc>> *tables,
const string &file, bool in_memory) {
using namespace clang;
......
......@@ -27,7 +27,7 @@ class LLVMContext;
namespace ebpf {
class BPFTable;
class TableDesc;
namespace cc {
class Parser;
......@@ -38,8 +38,7 @@ class ClangLoader {
public:
explicit ClangLoader(llvm::LLVMContext *ctx);
~ClangLoader();
int parse(std::unique_ptr<llvm::Module> *mod,
std::unique_ptr<std::map<std::string, BPFTable>> *tables,
int parse(std::unique_ptr<llvm::Module> *mod, std::unique_ptr<std::vector<TableDesc>> *tables,
const std::string &file, bool in_memory);
private:
llvm::LLVMContext *ctx_;
......
/*
* Copyright (c) 2015 PLUMgrid, Inc.
*
* Licensed 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 <cstdint>
#include <string>
namespace llvm {
class Function;
}
namespace ebpf {
struct TableDesc {
std::string name;
int fd;
size_t key_size; // sizes are in bytes
size_t leaf_size;
size_t max_entries;
std::string key_desc;
std::string leaf_desc;
llvm::Function *key_reader;
llvm::Function *leaf_reader;
};
} // namespace ebpf
......@@ -45,6 +45,8 @@ lib.bpf_table_key_desc.restype = ct.c_char_p
lib.bpf_table_key_desc.argtypes = [ct.c_void_p, ct.c_char_p]
lib.bpf_table_leaf_desc.restype = ct.c_char_p
lib.bpf_table_leaf_desc.argtypes = [ct.c_void_p, ct.c_char_p]
lib.bpf_table_update.restype = ct.c_int
lib.bpf_table_update.argtypes = [ct.c_void_p, ct.c_char_p, ct.c_char_p, ct.c_char_p]
# keep in sync with libbpf.h
lib.bpf_get_next_key.restype = ct.c_int
......@@ -258,6 +260,12 @@ class BPF(object):
leaftype = BPF._decode_table_type(json.loads(leaf_desc.decode()))
return BPF.Table(self, map_fd, keytype, leaftype)
def update_table(self, name, key, leaf):
res = lib.bpf_table_update(self.module, name.encode("ascii"), key.encode("ascii"),
leaf.encode("ascii"))
if res < 0:
raise Exception("update_table failed")
@staticmethod
def attach_raw_socket(fn, dev):
if not isinstance(fn, BPF.Function):
......
......@@ -46,5 +46,24 @@ int count_foo(struct pt_regs *ctx, unsigned long a, unsigned long b) {
b = BPF(text=text, debug=0)
fn = b.load_func("count_foo", BPF.KPROBE)
def test_sscanf(self):
text = """
BPF_TABLE("hash", int, struct { u64 a; u64 b; u64 c:36; u64 d:28; struct { u32 a; u32 b; } s; }, stats, 10);
int foo(void *ctx) {
return 0;
}
"""
b = BPF(text=text, debug=0)
fn = b.load_func("foo", BPF.KPROBE)
b.update_table("stats", "2", "{ 2 3 0x1000000004 { 5 6 }}")
t = b.get_table("stats")
l = t[t.Key(2)]
self.assertEqual(l.a, 2)
self.assertEqual(l.b, 3)
self.assertEqual(l.c, 4)
self.assertEqual(l.d, 1)
self.assertEqual(l.s.a, 5)
self.assertEqual(l.s.b, 6)
if __name__ == "__main__":
main()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment