mirror of
https://gitee.com/willfree/mlsr.git
synced 2026-06-19 15:04:25 +08:00
61 lines
1.2 KiB
Go
61 lines
1.2 KiB
Go
// Package common
|
|
// @Author: Wang Feng
|
|
// @Description:
|
|
// @Version: 0.1.0
|
|
// @Date: 2022/3/29 17:14
|
|
// @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室
|
|
//
|
|
|
|
package common
|
|
|
|
import (
|
|
"fmt"
|
|
"log"
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
func getCurrentDirectory() string {
|
|
dir, err := filepath.Abs(filepath.Dir(os.Args[0]))
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
fmt.Println(dir)
|
|
return dir
|
|
}
|
|
|
|
//
|
|
// TestMlsrConfig_ParseConfigAndSave
|
|
// @Description: 测试配置文件解析和存储
|
|
// @param t
|
|
//
|
|
func TestMlsrConfig_ParseConfigAndSave(t *testing.T) {
|
|
testPath := "D:"
|
|
testPath += "\\"
|
|
testPath += DefaultConfFileName
|
|
fmt.Println("test mlsr conf path: "+testPath)
|
|
mlsrConfig,_ := ParseConfig(testPath)
|
|
|
|
// 存储
|
|
fmt.Println(mlsrConfig)
|
|
_ = mlsrConfig.Save()
|
|
|
|
// 取出
|
|
mlsrConfig2,_ := ParseConfig(testPath)
|
|
fmt.Println(mlsrConfig2)
|
|
|
|
// 解析neighbors
|
|
neighbors := mlsrConfig2.neighbors
|
|
fmt.Println(neighbors)
|
|
|
|
// 修改再存
|
|
ss:=NeighborConfig{
|
|
NeighborName: "nei",
|
|
LogicFaceUri: "uri",
|
|
LinkCost: 0,
|
|
}
|
|
mlsrConfig2.neighbors = append(mlsrConfig2.neighbors,ss)
|
|
_ = mlsrConfig2.Save()
|
|
}
|